Ubuntu设置SSH免密登录(不同于CentOS)
来源:互联网 发布:财经日历软件 编辑:程序博客网 时间:2024/06/05 17:46
Ubuntu设置SSH免密登录(不同于CentOS)
1.遇到的坑
之前一直在CentOS系统进行Hadoop开发,SSH免密登录配置过N次,今天在Ubuntu平台下设置免密登录遇到了坑:
kylin@uk0:~$ ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsaGenerating public/private dsa key pair.Created directory '/home/kylin/.ssh'.Your identification has been saved in /home/kylin/.ssh/id_dsa.Your public key has been saved in /home/kylin/.ssh/id_dsa.pub.The key fingerprint is:SHA256:Kp2T562S8CP1Ui7LJMDlFAMBqujJ8HyrhvsAfWHu8X8 kylin@uk0The key's randomart image is:+---[DSA 1024]----+|..ooo ||. o ||. = ||oo * . ||= + = S ||=o.+.+.+. ||.=o =+O=. ||.....*B=o.E ||.+o...o*+o. |+----[SHA256]-----+kylin@uk0:~$ cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keyskylin@uk0:~$ chmod 0600 ~/.ssh/authorized_keys
免密登录本机时,竟然需要输入密码!?
kylin@uk0:~$ ssh uk0The authenticity of host 'uk0 (192.168.1.160)' can't be established.ECDSA key fingerprint is SHA256:dOKnH/ES8JcWzGkdRwRzYGzDkBE8y7cJpRx/DNHhGVc.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added 'uk0,192.168.1.160' (ECDSA) to the list of known hosts.kylin@uk0's password: Welcome to Ubuntu 16.10 (GNU/Linux 4.8.0-22-generic x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage279 个可升级软件包。107 个安全更新。Last login: Fri Mar 3 15:20:29 2017 from 192.168.1.81kylin@uk0:~$
2.解决办法
2.1 先删除之前的.ssh
kylin@uk0:~$ rm -rf .ssh
2.2 生成免密
与CentOS不同,需要使用ssh-keygen -t rsa命令生成,一直按Enter,按到最后。
kylin@uk0:~$ ssh-keygen -t rsaGenerating public/private rsa key pair.Enter file in which to save the key (/home/kylin/.ssh/id_rsa): Created directory '/home/kylin/.ssh'.Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/kylin/.ssh/id_rsa.Your public key has been saved in /home/kylin/.ssh/id_rsa.pub.The key fingerprint is:SHA256:Onr5G6x8pcsmksQNuMECb2oOu7lKoOzGPh0+x6y0Pj4 kylin@uk0The key's randomart image is:+---[RSA 2048]----+| ||. ||.o . ||. * . ||.+ + o S ||*...o .o . ||*+oo+.o.oo ||+*.E+*+++. ||O=+=Boo==o |+----[SHA256]-----+kylin@uk0:~$ cat .ssh/id_rsa.pub >> .ssh/authorized_keys
2.3 免密登录本机
kylin@uk0:~$ ssh uk0The authenticity of host 'uk0 (192.168.1.160)' can't be established.ECDSA key fingerprint is SHA256:dOKnH/ES8JcWzGkdRwRzYGzDkBE8y7cJpRx/DNHhGVc.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added 'uk0,192.168.1.160' (ECDSA) to the list of known hosts.Welcome to Ubuntu 16.10 (GNU/Linux 4.8.0-22-generic x86_64)Last login: Fri Mar 3 16:11:16 2017 from 192.168.1.160kylin@uk0:~$
3 集群免密登录
3.1 第2个节点生成免密
kylin@uk1:~$ rm -rf .sshkylin@uk1:~$ ssh-keygen -t rsaGenerating public/private rsa key pair.Enter file in which to save the key (/home/kylin/.ssh/id_rsa): Created directory '/home/kylin/.ssh'.Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/kylin/.ssh/id_rsa.Your public key has been saved in /home/kylin/.ssh/id_rsa.pub.The key fingerprint is:SHA256:pGAXPlmDGitJNPmUGXcS2ZZrQw581nTH7Y7zzUTU1Fs kylin@uk1The key's randomart image is:+---[RSA 2048]----+| .o..===++. ...o+|| o.=o=*B... .. E|| . +o+=B.. oo|| o.+o += .o|| . ..S. + || o o|| =.|| +|| |+----[SHA256]-----+kylin@uk1:~$ cat .ssh/id_rsa.pub >> .ssh/authorized_keyskylin@uk1:~$ ssh uk1The authenticity of host 'uk1 (192.168.1.161)' can't be established.ECDSA key fingerprint is SHA256:dOKnH/ES8JcWzGkdRwRzYGzDkBE8y7cJpRx/DNHhGVc.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added 'uk1,192.168.1.161' (ECDSA) to the list of known hosts.Welcome to Ubuntu 16.10 (GNU/Linux 4.8.0-22-generic x86_64)Last login: Fri Mar 3 16:23:19 2017 from 192.168.1.161kylin@uk1:~$
3.2 第3个节点生成免密
kylin@uk2:~$ rm -rf .sshkylin@uk2:~$ ssh-keygen -t rsaGenerating public/private rsa key pair.Enter file in which to save the key (/home/kylin/.ssh/id_rsa): Created directory '/home/kylin/.ssh'.Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/kylin/.ssh/id_rsa.Your public key has been saved in /home/kylin/.ssh/id_rsa.pub.The key fingerprint is:SHA256:/chD0D2CNj5iryn7Jue5lLxXzq3RAjwtG7Jrasz0KYk kylin@uk2The key's randomart image is:+---[RSA 2048]----+| || o . || = o o || + = . . || + S + || .o * X.+ || = o=.o+*.o || E O.**. o+. || .o%Xo .. |+----[SHA256]-----+kylin@uk2:~$ cat .ssh/id_rsa.pub >> .ssh/authorized_keyskylin@uk2:~$ ssh uk2The authenticity of host 'uk2 (192.168.1.162)' can't be established.ECDSA key fingerprint is SHA256:dOKnH/ES8JcWzGkdRwRzYGzDkBE8y7cJpRx/DNHhGVc.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added 'uk2,192.168.1.162' (ECDSA) to the list of known hosts.Welcome to Ubuntu 16.10 (GNU/Linux 4.8.0-22-generic x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantageLast login: Fri Mar 3 16:03:44 2017 from 192.168.1.160kylin@uk2:~$
3.3 分发公钥
kylin@uk1:~$ cat ~/.ssh/authorized_keysssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCisjV42WGpF64EffoSVB1fxXGqwE/9uYuDgwHzfXK47c54vLLtGfpKqzzXf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utR7kXosL2aoU2480LUtQLqo7yJ1mT+FUE2uuMR kylin@uk0ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCisjV42WGpF64EffoSVB1fxXGqwE/9uYuDgwHzfXK47c54vLLtGfpKqzzXfDoTLWtR1P/W5stGGqLxarP27Nz7ujd4rQKt3t8JXSnlQIIhkojo4JGcF3JDAm9V5nGaqpMse65tbdK24+tkmVolwfZJTOZi9O1bctzBaZOapzu498/2Tlzy1jSToQmDlT0zsAhbs1ipF1aBRLzjnU0i9gXhF2dW2pQvvJk1TBMx8A1xIPAviQ43NhUoNsUhZYeRIQ9XPe293/48tId3a3M4OvQ26tHLEiG8sDRl3w5Nc2NXybs4RVydAmiCS4kh/SgALgtpq/HF3SpWlbYXl4S5j1cb kylin@uk1ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDFdBdhmycLgyu4D/i3cneY4ERwnj/a2Q8JFHLizAg66qul7mykOIziI9IKRfE8nS4/vsOLTtUiTMsNqvpuWWGoibRXmxnrf19IwfyQ/YIuwllQ3Bm439Gyn+s2frK8i5Sw5wyCw+FiL4BS8WpPr4qWHXHajBI2VP4SNZuLdPlvCoZXYawWVOvlk8skt5WuXKpEjNEku+4w1Dyq3pT76iDBGxGk/JYzZRvyvUvQdBcYNgWjZNcva8HWYXpckmuoHh8VmeRDRhj1KGADsypw0L1jM7HG2hnGulqb3Xil2KJdMiPzp9uGJskSfZbLI6v7QLkQqOIpSAtIFZd+IxHwxIaF kylin@uk2
分发公钥
kylin@uk0:~$ scp .ssh/authorized_keys kylin@192.168.1.161:/home/kylin/.sshThe authenticity of host '192.168.1.161 (192.168.1.161)' can't be established.ECDSA key fingerprint is SHA256:dOKnH/ES8JcWzGkdRwRzYGzDkBE8y7cJpRx/DNHhGVc.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added '192.168.1.161' (ECDSA) to the list of known hosts.kylin@192.168.1.161's password: authorized_keys 100% 1173 692.4KB/s 00:00 kylin@uk0:~$ scp .ssh/authorized_keys kylin@192.168.1.162:/home/kylin/.sshThe authenticity of host '192.168.1.162 (192.168.1.162)' can't be established.ECDSA key fingerprint is SHA256:dOKnH/ES8JcWzGkdRwRzYGzDkBE8y7cJpRx/DNHhGVc.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added '192.168.1.162' (ECDSA) to the list of known hosts.kylin@192.168.1.162's password: authorized_keys 100% 1173 1.1MB/s 00:00 kylin@uk0:~$
3.4 集群免密登录
kylin@uk0:~$ ssh uk1The authenticity of host 'uk1 (192.168.1.161)' can't be established.ECDSA key fingerprint is SHA256:dOKnH/ES8JcWzGkdRwRzYGzDkBE8y7cJpRx/DNHhGVc.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added 'uk1' (ECDSA) to the list of known hosts.Welcome to Ubuntu 16.10 (GNU/Linux 4.8.0-22-generic x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage279 个可升级软件包。107 个安全更新。Last login: Fri Mar 3 16:24:21 2017 from 192.168.1.161kylin@uk1:~$ kylin@uk1:~$ ssh uk2The authenticity of host 'uk2 (192.168.1.162)' can't be established.ECDSA key fingerprint is SHA256:dOKnH/ES8JcWzGkdRwRzYGzDkBE8y7cJpRx/DNHhGVc.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added 'uk2,192.168.1.162' (ECDSA) to the list of known hosts.Welcome to Ubuntu 16.10 (GNU/Linux 4.8.0-22-generic x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage279 个可升级软件包。107 个安全更新。Last login: Fri Mar 3 16:25:05 2017 from 192.168.1.162
0 0
- Ubuntu设置SSH免密登录(不同于CentOS)
- Ubuntu设置SSH免密登录(不同于CentOS)
- ubuntu免密ssh登录
- Ubuntu ssh 免密登录
- ssh免密登录设置
- ssh免密登录设置
- CentOS免密登录设置
- [备忘]CentOS 7.2 SSH免密登录
- SSH免登录设置
- SSH免登录设置
- 如何在 CentOS / RHEL 上设置 SSH 免密码登录
- 在CentOS/RHEL上设置SSH免密码登录
- 如何在 CentOS / RHEL 上设置 SSH 免密码登录
- 关于Centos 7设置host,并配置ssh免登录
- linux设置ssh免密登录
- Ubutu之间ssh免密登录设置
- hadoop 节点SSH免密登录设置
- centos ssh免密码登录
- XML基础
- React Native 封装原生UI组件并使用的流程(iOS)
- 夫妻性生活和谐的秘诀
- HTML中Array的用法
- ApiDemo--Animation/Seeking
- Ubuntu设置SSH免密登录(不同于CentOS)
- js锁定表头和列,实现类似execl锁定效果
- Android性能优化
- react生命周期
- 重启网卡出现提示:Error, some other host already uses address 10.10.10.25.
- quick-cocos 下载
- thinkpad x230i 笔记本安装win2003操作系统方法
- 十大Intellij IDEA快捷键
- JS中10进制转16进制(小细节)