CentOS 7.3非root用户配置ssh免密码登陆
配置流程:
客户端:生成密钥公钥 服务端:添加公钥
具体方法:
切换到非root用户
# su YOURUSERNAME
生成密钥
$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/YOURUSERNAME/.ssh/id_rsa):
Created directory '/home/YOURUSERNAME/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/YOURUSERNAME/.ssh/id_rsa.
Your public key has been saved in /home/YOURUSERNAME/.ssh/id_rsa.pub.
The key fingerprint is:
XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX YOURUSERNAME@iZm5e8xckalnjb4dlz2ppdZ
The key's randomart image is:
+--[ RSA 2048]----+
| .o |
| .. |
| +.oo |
| . .E . |
| S .. = |
| . . + + |
| . B o |
| . O |
| =.. |
+-----------------+
查看公钥
$ cat ~/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDwrQo9Yd/xcQW79VlCTsUqoyBmTutPgguYoFDh3wWHJrLKm3XnpZl5MaeC3r7LA4e3w51gL6O3jfK1Qd6+6iyP4vU4YATKqbnsyksF0PGeN0byQMCYDNmy816HRkEexwh4gu2EfHqRugGuoSrbwXCFLKvdQH9bNie6P7adfeb//6pZPjosqkQ4EHTUZpvx8N3MpglVb/trOIjRRqLw5aBo27YJJqeFmI727E1UCwUXHTijwAvl+bhGmdgnRdABhLt+IzhkQY6IgEWVsvRmoQSfiQnqWf YOURUSERNAME@iZm5e8xckalnjb4dlz2ppdZ*
将上面的公钥交给服务端即可