我在 VirtualBox 上使用 Linux 終端機開發我的網站,無需密碼身份驗證即可安全存取遠端伺服器。我需要輸入的只是“ssh {sudo user}@{IP}”。管道破裂後,我就失去了重新連接的能力。
認為這是與防火牆相關的問題,我回顧了我的步驟(這很容易,因為我正在遵循本教程:https://www.youtube.com/watch?v=goToXTC96Co&t=318s)。這樣做時,我發現在啟用 ssh 訪問之前我已經允許了它,所以我認為不是防火牆導致的。
在認為這是與金鑰相關的問題後,我產生了一個新的金鑰對(不小心覆蓋了舊的金鑰對),並嘗試將產生的公鑰安全複製到伺服器,但無法運作。透過覆蓋伺服器上的公鑰的私鑰,我可能已經搞砸了自己,但作為新手,可能還有其他我不知道的解決方案。時間這是我現在得到的輸出(帶有調試信息):
root@john-VirtualBox:/home/john# ssh [email protected] -v
OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n 7 Dec 2017
- debug1: Reading configuration data /etc/ssh/ssh_config
- debug1: /etc/ssh/ssh_config line 19: Applying options for *
- debug1: Connecting to xxx.xxx.xx.xxx [xxx.xxx.xx.xxx] port 22.
- debug1: Connection established.
- debug1: permanently_set_uid: 0/0
- debug1: identity file /root/.ssh/id_rsa type 0
- debug1: key_load_public: No such file or directory
- debug1: identity file /root/.ssh/id_rsa-cert type -1
- debug1: key_load_public: No such file or directory
- debug1: identity file /root/.ssh/id_dsa type -1
- debug1: key_load_public: No such file or directory
- debug1: identity file /root/.ssh/id_dsa-cert type -1
- debug1: key_load_public: No such file or directory
- debug1: identity file /root/.ssh/id_ecdsa type -1
- debug1: key_load_public: No such file or directory
- debug1: identity file /root/.ssh/id_ecdsa-cert type -1
- debug1: key_load_public: No such file or directory
- debug1: identity file /root/.ssh/id_ed25519 type -1
- debug1: key_load_public: No such file or directory
- debug1: identity file /root/.ssh/id_ed25519-cert type -1
- debug1: Local version string SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.3
- debug1: Remote protocol version 2.0, remote software version
OpenSSH_7.6p1 Ubuntu-4ubuntu0.3
- debug1: match: OpenSSH_7.6p1 Ubuntu-4ubuntu0.3 pat OpenSSH* compat
0x04000000
- debug1: Authenticating to xxx.xxx.xx.xxx:22 as 'jw'
- debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received
- debug1: kex: algorithm: curve25519-sha256
- debug1: kex: host key
- algorithm: rsa-sha2-512
- debug1: kex: server->client cipher:[email protected] MAC
<implicit> compression: none
- debug1: kex: client->server cipher: [email protected]
MAC: <implicit> compression: none
- debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
- debug1: Server host key: ssh-rsa SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
- debug1: Host 'xxx.xxx.xx.xxx' is known and matches the RSA host key.
- debug1: Found key in /root/.ssh/known_hosts:4
- debug1: rekey after 134217728 blocks
- debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS
- debug1: SSH2_MSG_NEWKEYS received debug1: rekey after 134217728 blocks
- debug1: SSH2_MSG_EXT_INFO received
- debug1:
kex_input_ext_info:server-sig-algs=<ssh-ed25519,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521>
- debug1: SSH2_MSG_SERVICE_ACCEPT received
- debug1: Authentications that can continue: publickey
- debug1: Next authentication method: publickey
- debug1: Offering public key: RSA
SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx /root/.ssh/id_rsa
- debug1: Authentications that can continue: publickey
- debug1: Trying private key: /root/.ssh/id_dsa
- debug1: Trying private key: /root/.ssh/id_ecdsa
- debug1: Trying private key: /root/.ssh/id_ed25519
- debug1: No more authentication methods to try.
這是我收到的錯誤輸出(沒有調試資訊):
[email protected]: Permission denied (publickey)
/etc/ssh/sshd_config 在發布之前更改了設定:
- PermitRootLogin no(防止駭客取得root存取權限)
- PasswordAuthentication no(允許我無需每次都輸入密碼即可進行 ssh)