Option 1: SSH without needing your password
1 ) You are A. You want to SSH to B.
2) Generate SSH keys on A. *Don’t* type a password, leave blank when prompted.
a@A:~> ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/home/a/.ssh/id_rsa): Created directory '/home/a/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/a/.ssh/id_rsa. Your public key has been saved in /home/a/.ssh/id_rsa.pub. The key fingerprint is: 3e:4f:05:79:3a:9f:96:7c:3b:ad:e9:58:37:bc:37:e4 a@A
3) Create a directory ~/.ssh as user b on B if one doesn’t exist.
a@A:~> ssh b@B mkdir -p ~/.ssh b@B's password:
4) Append a’s new public key to b@B:.ssh/authorized_keys and enter b’s password one last time:
a@A:~> cat ~/.ssh/id_rsa.pub | ssh b@B 'cat >> .ssh/authorized_keys' b@B's password:
5) Now you need no password.
a@A:~> ssh b@B hostname
Option 2: SSH without needing your password
$ ssh-agent bash $ ssh-add ~/.ssh/id_rsa $ ssh username@remote
Tunnelling through multiple logins is really easy but you have to do the above for all the hosts that you want to automatically hop over.
Sort out your intermediate hosts so you can auto-ssh into them as above. Then run:
$ ssh -t user@intermediateserver.com ssh user@finaldestination.com