![將 id_rsa.pub 新增至遠端電腦後,ssh passwdless 失敗](https://rvso.com/image/1490229/%E5%B0%87%20id_rsa.pub%20%E6%96%B0%E5%A2%9E%E8%87%B3%E9%81%A0%E7%AB%AF%E9%9B%BB%E8%85%A6%E5%BE%8C%EF%BC%8Cssh%20passwdless%20%E5%A4%B1%E6%95%97.png)
我的遠端機器有 2 個用戶,一個是root
,另一個是Alexander
。我fit
用root
user 建立一個新使用者。
# adduser fit
我將我的家用電腦scp
新增到授權密鑰中。id_rsa.pub
fit@remote_machine
fit$ cat id_rsa.pub >> ~/.ssh/authorized_keys
但是,之後我仍然需要輸入密碼才能登入遠端機器
home$ ssh fit@remote_machine
fit@remote_machine's password:
Last login: Fri Apr 15 09:55:34 2016
[email protected]:[/home/fit]
但是,真正讓我困惑的是,我將我的家用機器scp
添加到了。我可以在沒有密碼的情況下登入遠端電腦:id_rsa.pub
Alexander@remote_machine
authorized_keys
Alexander@remote_machine
home$ ssh alexander@remote_machine # login without passwd
Last login: Fri Apr 15 09:58:19 2016 from 27.46.137.183
/etc/profile:fc:80: no such event: 1
Alexander@localhost: ~
謝謝!
答案1
正是權限導致ssh passwdless連線失敗。更改權限
$ chmod 700 .ssh
$ chmod 600 authorized_keys
現在,效果很好。