> For the complete documentation index, see [llms.txt](https://sarpers-organization.gitbook.io/ctftricks/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sarpers-organization.gitbook.io/ctftricks/_chapter-intro-13/linux/shell-stabilization/trick-0357.md).

# Deploy SSH Key for Stable Shell

***

Generate an SSH key pair on your attacker machine. The `ssh-keygen` command creates a pair of cryptographic keys: a public key and a private key. The private key should remain secure on the client machine. It is recommended to use the `ed25519` key type for modern security and performance.

```bash
ssh-keygen -t ed25519
```

The `authorized_keys` file in SSH is a file that stores public keys. An authorized key is a public key used for authentication, stored in the user's `.ssh` directory. Authorized keys specify which users are allowed to log in using SSH key authentication.

From your existing shell on the target (e.g., an unstable reverse shell), append the content of your *public* key (the `.pub` file) to the target user's `authorized_keys` file. Remember to replace `<your-public-key-content>` with the actual key string.

```bash
echo "<your-public-key-content>" >> /home/paradox/.ssh/authorized_keys
```

Now, you can connect directly via SSH using your private key for a stable shell.

```bash
ssh -i id_ed25519 paradox@10.10.139.53
```

This provides a much more stable and reliable command-line interface compared to many initial shell types, assuming you have write permissions to the target `.ssh` directory. It is important to note that the `.ssh` directory permissions should be `700` (read, write, and execute for the owner only) and the `authorized_keys` file permissions should be `600` (read and write for the owner only).
