linux:ssh:public-key-authentication
                Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| linux:ssh:public-key-authentication [2024/09/03 12:01] – odefta | linux:ssh:public-key-authentication [2024/09/03 12:10] (current) – odefta | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Public key authentication to remote ssh server ====== | ||
| - | < | + | 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) | ||
| + | |||
| + | < | ||
| cd ~/.ssh/ | cd ~/.ssh/ | ||
| </ | </ | ||
| 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. | ||
| < | < | ||
| + | ssh-copy-id -i ~/ | ||
| </ | </ | ||
| + | |||
| + | Connect to remote_ssh_server and edit / | ||
| + | < | ||
| + | vi / | ||
| + | PubkeyAuthentication yes | ||
| + | |||
| + | systemctl restart sshd | ||
| + | </ | ||
| + | |||
| + | On the host machine (exit from the remote one): | ||
| + | |||
| + | Edit ~/ | ||
| + | |||
| + | < | ||
| + | vi ~/ | ||
| + | |||
| + | Host remote_ssh_server | ||
| + | User root | ||
| + | IdentityFile ~/ | ||
| + | </ | ||
| + | |||
| + | Now you can connect without password: | ||
| + | < | ||
| + | ssh root@remote_ssh_server | ||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
linux/ssh/public-key-authentication.1725364869.txt.gz · Last modified:  by odefta
                
                