User Tools

Site Tools


linux:ssh:public-key-authentication

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
linux:ssh:public-key-authentication [2024/09/03 15:01] odeftalinux:ssh:public-key-authentication [2024/09/03 15:10] (current) odefta
Line 1: Line 1:
 +====== Public key authentication to remote ssh server ======
  
-<code sh>+Create a SSH key-pair and set a custom name for it to not override the existing one. \\  
 +Change id_rsa with a custom name (for example id_rsa_odcent8) 
 + 
 +<code bash>
 cd ~/.ssh/ cd ~/.ssh/
 </code> </code>
Line 17: Line 21:
   Your public key has been saved in id_rsa_odcent8.pub   Your public key has been saved in id_rsa_odcent8.pub
  
 +Copy the public key to the remote machine.
 <code> <code>
 +ssh-copy-id -i ~/.ssh/id_rsa_odcent8.pub root@remote_ssh_server
 </code> </code>
 +
 +Connect to remote_ssh_server and edit /etc/ssh/sshd_config:
 +<code>
 +vi /etc/ssh/sshd_config
 +PubkeyAuthentication yes
 +
 +systemctl restart sshd
 +</code>
 +
 +On the host machine (exit from the remote one):
 +
 +Edit ~/.ssh/config file and add:
 +
 +<code>
 +vi ~/.ssh/config
 +
 +Host remote_ssh_server
 +    User root
 +    IdentityFile ~/.ssh/id_rsa_odcent8
 +</code>
 +
 +Now you can connect without password:
 +<code>
 +ssh root@remote_ssh_server
 +</code>
 +
 +
 +
 +
 +
linux/ssh/public-key-authentication.1725364869.txt.gz · Last modified: 2024/09/03 15:01 by odefta