ubuntu(16.04) 系统相互在root下免密ssh

来源:互联网 发布:判断微信浏览器 js 编辑:程序博客网 时间:2024/06/07 17:43

1  保证几台机器能够在root下能ssh

首先是要进入登陆账号设置root密码  sudo passwd root(root 初始密码位空, 可以用sudo -i 或者 sudo -s -H进入)

再是安装openssh(apt-get install openssh-server -y), 并且设置其让root可以ssh("/etc/ssh/sshd_config", 注释#PermitRootLogin prohibit-password
添加 PermitRootLogin yes)  , 再重启ssh service ssh restart

最后看防火墙是不是阻止了22端口, 有的话需要添加22端口 (ufw allow 22), 再重启 ufw reload, ufw enable

2  生成公约并copy到相应的机器上

在每台机器上运行: cd /root/.ssh   ssh-keygen -t rsa (回车到底)  run ssh-copy-id   -i   id_rsa.pub root@host


到此不出意外就可以了 .

3 问题:

在第二步的时候可能回遇到如下的问题:  这是需要运行ssh-keygen -f "/root/.ssh/known_hosts" -R 192.168.56.110 , 然后再执行第二部


@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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 ECDSA key sent by the remote host is
SHA256:+XEkEDA0VKgc5sULvED4/xqS5ZXQVdKRI1GBVftt0cw.
Please contact your system administrator.
Add correct host key in /root/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /root/.ssh/known_hosts:2
  remove with:
  ssh-keygen -f "/root/.ssh/known_hosts" -R 192.168.56.110
ECDSA host key for 192.168.56.110 has changed and you have requested strict checking.
Host key verification failed.


我在此之前还发现我的ubuntu虚拟机不能root直接登陆, 后来就把/etc/lightdm/lightdm.conf  两面的 autologin-user 这位root就可以了  autologin-user=root





原创粉丝点击