SSH 免密登录

服务器执行, ssh-keygen , 连续三次回车

[syncd@VM_121_116_centos .ssh]$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/syncd/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/syncd/.ssh/id_rsa.
Your public key has been saved in /home/syncd/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:fLvONE5cJvkxA95kyJxygAxXWnwr9GO1zAkZTlhWLnc syncd@VM_121_116_centos
The key's randomart image is:
+---[RSA 2048]----+
|    .o.++o=+.    |
|     .oo+B++.    |
|      ...oX*=oE  |
|       ..+=O=.   |
|        So=.B    |
|         o * +   |
|          * .    |
|         = o     |
|         .=      |
+----[SHA256]-----+
[syncd@VM_121_116_centos .ssh]$ ll
total 12
-rw------- 1 syncd syncd 1675 Apr 10 15:06 id_rsa
-rw-r--r-- 1 syncd syncd  405 Apr 10 15:06 id_rsa.pub
-rw-r--r-- 1 syncd syncd  346 Apr 10 14:21 known_hosts

复制公钥到要登录的主机

[syncd@VM_121_116_centos .ssh]$ ssh-copy-id -i ~/.ssh/id_rsa.pub appl@118.23.121.117 -p 22522
/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/syncd/.ssh/id_rsa.pub"
The authenticity of host '[rjdev.hand-china.com]:22522 ([116.228.77.180]:22522)' can't be established.
ECDSA key fingerprint is SHA256:IR2YBFvxG8WOPIS3GGzL+n3jFHAbjcAEddMfCkkTsdg.
ECDSA key fingerprint is MD5:f5:dd:f8:00:17:f7:da:7a:42:5c:b0:2f:31:bd:d0:5e.
Are you sure you want to continue connecting (yes/no)? yes
/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
appl@rjdev.hand-china.com's password: 

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh -p '22522' 'appl@118.23.121.117 '"
and check to make sure that only the key(s) you wanted were added.

要访问的主机出现 authorized_keys

[appl@121_117 .ssh]$ ll
total 8
-rw-------  1 appl appl 405 Apr 10 15:12 authorized_keys
-rw-r--r--. 1 appl appl 640 Dec  8  2017 known_hosts

测试免密

[syncd@VM_121_116_centos .ssh]$ ssh -p 22522 appl@118.23.121.117
Last login: Wed Apr 10 14:56:55 2019 from 172.26.1.9

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值