將 id_rsa.pub 新增至遠端電腦後,ssh passwdless 失敗

將 id_rsa.pub 新增至遠端電腦後,ssh passwdless 失敗

我的遠端機器有 2 個用戶,一個是root,另一個是Alexander。我fitrootuser 建立一個新使用者。

# adduser fit

我將我的家用電腦scp新增到授權密鑰中。id_rsa.pubfit@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.pubAlexander@remote_machineauthorized_keysAlexander@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

現在,效果很好。

相關內容