Skip to content

Instantly share code, notes, and snippets.

@hosamshahin
Last active August 1, 2017 14:57
Show Gist options
  • Save hosamshahin/4b9caeba92e51c766755df235294df3b to your computer and use it in GitHub Desktop.
Save hosamshahin/4b9caeba92e51c766755df235294df3b to your computer and use it in GitHub Desktop.
# to connect to the server without password
- Open a terminal on your machine A as user a and generate a pair of authentication keys. Do not enter a passphrase:
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
- ssh to your server, and do the following
cd
mkdir .ssh
cd .ssh
touch authorized_keys
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
- Then append a's new public key to username@xyz.cs.vt.edu :.ssh/authorized_keys and enter b's password one last time:
a@A:~> cat .ssh/id_rsa.pub | ssh username@xyz.cs.vt.edu -p2222 'cat >> .ssh/authorized_keys'
b@B's password:
- From now on you can log into xyz.cs.vt.edu as b from A as a without password:
a@A:~> ssh username@xyz.cs.vt.edu -p2222
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment