SSH认证免密码登录

/ 0评 / 0

客户端:

#ssh-keygen -t rsa

Generating public/private rsa key pair.

Enter file in which to save the key (/Users/hisway/.ssh/id_rsa):

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /Users/hisway/.ssh/id_rsa.

Your public key has been saved in /Users/hisway/.ssh/id_rsa.pub.

The key fingerprint is:

0d:24:c6:8d:f0:d9:b2:01:08:67:89:8a:5f:20:8e:b7 hisway@hisway.lan

The key's randomart image is:

+--[ RSA 2048]----+

|.ooooooo.        |

|oo+  +o=.        |

|=. .  = o        |

|+.. .  + o       |

| o o  . S .      |

|  E              |

|                 |

|                 |

|                 |

+-----------------+

#scp /Users/hisway/.ssh/id_rsa.pub  root@162.243.*.*:/home/root/id_rsa.pub

服务端:

#cat id_rsa.pub >>/root/.ssh/authorized_keys

# vi /etc/ssh/sshd_config

RSAAuthentication yes

#RSA认证

PubkeyAuthentication yes

#开启公钥验证

AuthorizedKeysFile    .ssh/authorized_keys

#验证文件路径

PasswordAuthentication no

#禁止密码认证

PermitEmptyPasswords no

#禁止空密码

UsePAM no

#禁用PAM

最后保存,重启

#

service sshd restart