rsync:使用 SSH 拒絕權限(公鑰)

rsync:使用 SSH 拒絕權限(公鑰)

我有一台伺服器,透過 SSH 連接我的金鑰文件,例如id_rsa.pub.我在客戶端和伺服器端使用 Debian。

我按照教程禁用根身份驗證和密碼使用以提高安全性(透過/etc/ssh/sshd/sshd_config在伺服器上設定檔)。

到目前為止,我可以輕鬆地rsync將文件從我的電腦同步到伺服器。

幾天之前, 我使用了 cron 作業為此,我必須在伺服器端重置我的 root 密碼。

從那時起,我就不可能再rsync使用SSH;我收到以下訊息:

[email protected]: Permission denied (publickey).
rsync: connection unexpectedly closed (0 bytes received so far)[sender]
rsync error: unexplained error (code 255) at io.c(235)[sender=3.1.3]

有一些類似的主題,但我認為我的情況有點不同,因為我認為問題是由於在伺服器上重置密碼造成的。我還在 Ask Ubuntu 網站上提出了一個問題,但我認為也許這裡的人在權限問題上更專業。

我不知道如何解決這個問題(我在終端命令中進行了一些管理,但我不是電腦專家)。請問你能幫幫我嗎?

/etc/ssh/sshd_config僅供您參考,請參閱調整不使用密碼的教學:

#Uncomment or add the following line. 
#This allows the server to give its DSA footprint in case of an ssh connection.
HostKey /etc/ssh/ssh/ssh_host_dsa_key

#Then set the next parameter to 20s (for example). 
#This is the time during which a connection without being logged in will be opened. 
#If we had kept the good old password technique, leave 2 or 3 minutes to type it, it's not too much. 
#But since we're using the key now, we'll be logged in immediately. #So we can really reduce the thing and put it down to 20 seconds for example.
LoginGraceTime 20s

#this is the maximum number of attempts before being thrown by the server.... 
#Since with the key, no possible error, you can put it to 1 possible test.
MaxAuthTries 1

#Then, we will tell the SSH server where the keys are and tell it that we will use them as an authentication method
PubkeyAuthentication yes
AuthorizedKeysFile.ssh/authorized_keys

#And of course, we'll disable all other authentication methods
RSAAuthentication no.
UsePAM no
KerberosAuthentication no
GSSAPIA Authentication no.
PasswordAuthentication no

#Then, we will tell that we only allow users of the sshusers group (for more security)
AllowGroups sshusers

#The MaxStartups setting indicates the number of un-authenticated ssh connections you can launch at the same time. 
#2 is more than enough, knowing that with the keys, it's instantaneous.
MaxStartups 2

答案1

不好了!

我剛剛找到解決方案...我的命令是:

sudo rsync -avz -e "ssh -p <port>" <source> <destination>

但我必須簡單地做到這一點(沒有sudo):

rsync -avz -e "ssh -p <port>" <source> <destination>

我不確定原因,但我認為root我的桌面電腦的用戶不允許透過 SSH 存取我的伺服器,因為金鑰僅適用於我的classic桌面用戶(因此沒有 sudo)。

有人可以確認一下嗎?謝謝。

相關內容