為什麼必須使用 sudo 才能進行 ssh 公鑰驗證?

為什麼必須使用 sudo 才能進行 ssh 公鑰驗證?

我無法從我的電腦 (OS X) ssh 到我的樹莓派 (ubuntu mate),除非我使用 sudo。我正在使用公鑰/私鑰對進行身份驗證。

適當的公鑰將會加入到樹莓派上的authorized_users 檔案中。

我的 .ssh 目錄的權限是 700。

這是帶有 -v 標誌的 ssh 的輸出:

debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/username/.ssh/id_rsa
debug1: Authentications that can continue: publickey 
debug1: Trying private key: /Users/username/.ssh/id_dsa
debug1: No more authentication methods to try. Permission denied (publickey).

LS:

-rw------- 1 username staff 3326 May 18 23:24 id_rsa 
-rw-r--r-- 1 username staff 752 May 18 23:24 id_rsa.pub 

.ssh:

drwx------  11 username   staff    374 May 19 21:49 .ssh

答案1

您可能共用 root 的 ssh 金鑰,也許透過執行sudowhen you did ssh-copy-id。確保username的公鑰也在authorized_keys目的地中

答案2

這裡似乎存在脫節。你一直說authorized_users;其他人一直說authorized_keys。使用者的公鑰被放入使用者主目錄中名為 .ssh/authorized_keys 的檔案中,而不是 .ssh/authorized_users 中。由於 ssh 適用於 root,因此您可能需要查看 ~root/.ssh 的目錄並使 ~user_name/.ssh 的目錄看起來相同 - 當然,除了金鑰將是該使用者的金鑰之外,不適用於根。

相關內容