簡體   English   中英

gcloud:ssh-ing到服務器時權限被拒絕(公鑰)

[英]gcloud: permission denied (public key) when ssh-ing to server

我正在嘗試為gcloud實例設置一個新的ssh密鑰。 我按照這里的說明逐字( https://cloud.google.com/compute/docs/instances/adding-removing-ssh-keys ),生成一個新密鑰,將公共rsa-ssh密鑰與我的用戶名放在SSH上Google Cloud Platform界面中“元數據”選項卡的“鍵”部分,並使用chmod為我的公鑰和私鑰設置適當的權限。

當我嘗試使用-vvv verbose標志時,我收到的錯誤如下所示:

...

debug1: Next authentication method: publickey debug1: Offering RSA public key: /Users/erickofman/.ssh/salsadb debug3: send_pubkey_test debug3: send packet: type 50 debug2: we sent a publickey packet, wait for reply debug3: receive packet: type 51 debug1: Authentications that can continue: publickey debug2: we did not send a packet, disable method debug1: No more authentication methods to try. Permission denied (publickey).

我(與同事一起)確保我的公鑰包含在服務器的.ssh文件夾中的authorized_keys文件中。 想到也許某些事情只是陳舊,我也嘗試使用service sshd restart ssh服務器無濟於事。

我也嘗試使用gcloud工具設置ssh,結果相同。

從我所知道的,我對網站有正確的角色/權限。

這就是服務器端日志的樣子:

admin@awesome-website:~$ tail /var/log/auth.log Nov 15 20:40:16 awesome-website sshd[18846]: input_userauth_request: invalid user ekofman [preauth] Nov 15 20:40:17 awesome-website sshd[18846]: Connection closed by 10.100.100.10 port 90001 [preauth] Nov 15 20:41:17 awesome-website sshd[18848]: Connection closed by 200.200.20.20 port 90002 [preauth]

一直在敲我的頭一點,任何幫助非常感謝!

Whelp,事實證明,除非實現完整實例重啟,否則不會合並新的ssh密鑰。 不是ssh服務器重啟 ,而是重啟完整實例(停止gcloud實例,然后啟動gcloud實例)。 它沒有在文檔中說明這一點,很有必要將來參考。

為此,請確保您的用戶目錄中包含.ssh / authorized_keys。

您還需要確保.ssh目錄和authorized_keys具有適當的權限集。 (分別為700和600)。

sudo chmod 700 ~/.ssh
sudo chmod 600 ~/.ssh/authorized_keys

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM