Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hosamshahin/784e6c4e2293dbfafebb343f92cb9465 to your computer and use it in GitHub Desktop.
Save hosamshahin/784e6c4e2293dbfafebb343f92cb9465 to your computer and use it in GitHub Desktop.
# SSH authentication via keys
- Open a terminal on your local 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
- Log in to remote server and create a .ssh directory, and inside the .ssh/ directory create an authorized_keys
[dave@julia dave]$ mkdir .ssh
[dave@julia dave]$ chmod 700 .ssh
[dave@julia dave]$ cd .ssh
[dave@julia .ssh]$ touch authorized_keys
[dave@julia .ssh]$ chmod 600 authorized_keys
- Then append a's new public key to [email protected] :.ssh/authorized_keys and enter b's password one last time:
a@A:~> cat .ssh/id_rsa.pub | ssh [email protected] '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 [email protected]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment