我正在尝试设置ssh密钥登录,所以我可以在没有密码的情况下输入ssh slave01
来ssh进入奴隶机器,但是我在设置它时遇到了麻烦。主和从是运行Ubuntu的Vagrant盒子。
主箱具有以下设置
vagrant@vagrant-ubuntu-trusty-64:~$ ifconfig
...
inet addr:192.168.33.10 Bcast:192.168.33.255
vagrant@vagrant-ubuntu-trusty-64:~$ cat /etc/hosts
...
192.168.33.10 master
192.168.33.12 slave01
192.168.33.13 slave02
vagrant@vagrant-ubuntu-trusty-64:~/.ssh$ cat id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDWx6Zj6BLkd/Dz1ZY/YdzeHC6LGhx+bCdciYerm7q2x7DEAerbdFEsU68Dugso5PbROVCs68fCkVRdNeD7sAzgU0F8MFXRaiWGJNE8TM4NpzaiVDsiVd0V7334YM3hdFmD9uEshh3avIhzqbogtx0gHGerwizAyoVIaOC/OZKhd4GgBuUZchGB569s0Y2D4RYERA004OtGxSo1WzFmwIx64SS4bKF1Y/mKxRaU+aDuZMsO5CpsJ/KSKuBsqL1CX3ygupgivulYENYkWiCnm9R4o/jLDutpmOekm4Es0TdfaXo5m8Xu3kLYd0sk4LjAmSFw05waa7dmpGm+KIRHGDWx vagrant@vagrant-ubuntu-trusty-64
奴隶以下设置
vagrant@vagrant-ubuntu-trusty-64:~$ ifconfig
...
inet addr:192.168.33.12 Bcast:192.168.33.255
vagrant@vagrant-ubuntu-trusty-64:~/.ssh$ cat authorized_keys
# CLOUD_IMG: This file was created/modified by the Cloud Image build process
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC1hp+ytnJJ1r2qCHdX/t6HZoewGj+NyMDZY90udyXG7h58b2rHorT3XtIu2OB+r5mdiMFsXqTUIa+gSjU6LijMsEzaP4GpRmN8BgGzFyXYrX6LtCCKNBAVjtPTuyObKmvRihtTeN3ZkvDdwGKXgVqbGdqjyHQc/1WfV+mMKa5p7mSqesVZfhs2behvnrGfXsu5C8Us8oHcr13Qpm9fHIWT+F+kPlOeOfrIaMpg9pY3sd4YHhziLjwKZkpmZhQTT7pgqI2ySCEiZQRRQV5VMdnv/HvHcAmi83S7fgSJqCMu4e/Hw0QxkKnJlzE93ornRMbFy8t6IeOH8gwsMtoqyUxd vagrant
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDWx6Zj6BLkd/Dz1ZY/YdzeHC6LGhx+bCdciYerm7q\
2x7DEAerbdFEsU68Dugso5PbROVCs68fCkVRdNeD7sAzgU0F8MFXRaiWGJNE8TM4NpzaiVDsiVd0V73\
34YM3hdFmD9uEshh3avIhzqbogtx0gHGerwizAyoVIaOC/OZKhd4GgBuUZchGB569s0Y2D4RYERA004\
OtGxSo1WzFmwIx64SS4bKF1Y/mKxRaU+aDuZMsO5CpsJ/KSKuBsqL1CX3ygupgivulYENYkWiCnm9R4\
o/jLDutpmOekm4Es0TdfaXo5m8Xu3kLYd0sk4LjAmSFw05waa7dmpGm+KIRHGDWx vagrantvagrant@vagrant-ubuntu-trusty-64
当我从Master中的命令行运行以下命令时,它会一直询问密码。我不确定为什么会这样做。
vagrant@vagrant-ubuntu-trusty-64:~/.ssh$ ssh slave01
vagrant@slave01's password:
Permission denied, please try again.
vagrant@slave01's password:
Permission denied, please try again.
vagrant@slave01's password:
答案 0 :(得分:1)
尝试使用ssh-copy-id
在计算机之间移动ssh密钥。您可能没有在目录上设置正确的chmod
权限。