SSH Tricks

Here’s how you generate a public/private RSA key pair using the ssh-keygen command:

ssh-keygen -t rsa

Here’s how you copy your public SSH key to a remote serve such that you authenticate via your private key instead of your password.

ssh-copy-id -i ~/.ssh/id_rsa.pub user@hostname

Here’s how you create a reverse SSH tunnel from a server. From the destination server, you’ll set up an SSH tunnel into a relay server.

ssh -fN -R 10022:localhost:22 relay@hostname.com

From the relay server, you can now SSH into the destination server.

ssh destination@localhost -p 10022