[Linux] ssh key login

Login SSH keys

  • Generate a key pair

root @ ttkl: ~ # ssh- keygen == " establish key pair
Generating public / Private Key pair rsa.
the Enter the Save to File in Which at The Key (/root/.ssh/id_rsa): ==" press the Enter
the Created Directory ' /root/.ssh '.
the enter passphrase (empty for NO passphrase): == "enter key password
enter same passphrase again: ==" to confirm the input password
Your identification has been saved in /root/.ssh/id_rsa = . = "private Key
Your public key has been saved in /root/.ssh/id_rsa.pub ==." public Key
at The Key Fingerprint IS:
SHA256: the I / r1Ugm / cZftWSmfw0ce + 05zdWKINQ6kIEdnvzVaKko root @ ttkl

The key's randomart image is:
+ --- [RSA 2048] ---- +
| .. + a. |
| the + + |
| . o * |
| . @ + |
| And .the So = + oo |
| ooo = .oO * + |
| . . .. + = O. |
| . .... The * |
| . .. *. |
+ ---- [SHA256] + -----

 

  • Installation public

1, the public key is installed on the server:

root@ttkl:~# cd .ssh
root@ttkl:~/.ssh# cat id_rsa.pub >> authorized_keys

2, modify the file permissions for
root @ ttkl: ~ / .ssh # chmod 600 authorized_keys 
root @ ttkl: ~ / .ssh # chmod 700 ~ / .ssh

 

  • Modify the SSH configuration

1, edit / etc / ssh / sshd_config file

RSAAuthentication yes
PubkeyAuthentication yes
# Root user login
PermitRootLogin yes
# Disable Password
PasswordAuthentication no

  

2, restart the ssh service

service sshd restart

  

  • The private key can be downloaded to the client

 

Guess you like

Origin www.cnblogs.com/ttkl/p/11704585.html