本地免密码登录linux服务器

  • 2019-02-27
  • 0
  • 0

1.在本地执行公钥和私钥生产

$ ssh-keygen
#回车 回车 回车
$ cd ~/.ssh
$ ls
id_rsa id_rsa.pub

#此时公钥和私钥已创建在本地

2.将本地公钥上传到服务器上(如有其它服务器多次执行该命令)

$ ssh-copy-id {服务器账号}@{服务器ip}
#yes
#输入目标服务器密码

3.此时也完成授信操作,可直接连接目标服务器

retro $ ssh {服务器账号}@{服务器ip}

当提示如下代码,通常是访问目标主机的密码被修改了。

[user@hostname ~]$ ssh root@pong
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
6e:45:f9:a8:af:38:3d:a1:a5:c7:76:1d:02:f8:77:00.
Please contact your system administrator.
Add correct host key in /home/hostname /.ssh/known_hosts to get rid of this message.
Offending RSA key in /var/lib/sss/pubconf/known_hosts:4
RSA host key for pong has changed and you have requested strict checking.
Host key verification failed.

输入

ssh-keygen -R 192.168.3.10

删除旧目标的ip,重新按上面step2操作即可。

评论

还没有任何评论,你来说两句吧