Ssh

ssh -p 29418 user@samehostip 失敗

  • July 14, 2020

我在同一台主機上設置 jenkins 和 gerrit,我需要做的一件事是讓 gerrit 和 jenkins 相互通信。

當我添加主機的 IP 地址(比如 10.25.26.27)時,我無法讓 gerrit 觸發器連接到 10.25.26.27。為了調試,我嘗試了:

ssh -p 29418 user@10.25.26.27 -v 已完成對 ssh-keygen 和複製 id_rsa.pub 的盡職調查。

上述命令的輸出是:

debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to 10.25.26.27 [10.25.26.27] port 29418.
debug1: Connection established.
debug1: identity file /home/user/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /home/user/.ssh/id_rsa-cert type -1
debug1: identity file /home/user/.ssh/id_dsa type 2
debug1: key_load_public: No such file or directory
debug1: identity file /home/user/.ssh/id_dsa-cert type -1
debug1: identity file /home/user/.ssh/id_ecdsa type 3
debug1: key_load_public: No such file or directory
debug1: identity file /home/user/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/user/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/user/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.10
debug1: Remote protocol version 2.0, remote software version GerritCodeReview_3.2.2 (APACHE-SSHD-2.4.0)
debug1: no match: GerritCodeReview_3.2.2 (APACHE-SSHD-2.4.0)
debug1: Authenticating to 10.25.26.27:29418 as 'user'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: ecdh-sha2-nistp256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: aes128-ctr MAC: hmac-sha2-256-etm@openssh.com compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: hmac-sha2-256-etm@openssh.com compression: none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:y/+sp8pk2QcG5EXarPQs3zZrmvbf23ZKp8BF6gtZHEY
debug1: Host '[10.25.26.27]:29418' is known and matches the ECDSA host key.
debug1: Found key in /home/user/.ssh/known_hosts:2
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 4294967296 blocks
debug1: pubkey_prepare: ssh_get_authentication_socket: No such file or directory
debug1: Skipping ssh-dss key /home/user/.ssh/id_dsa - not in PubkeyAcceptedKeyTypes
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/user/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Offering ECDSA public key: /home/user/.ssh/id_ecdsa
debug1: Authentications that can continue: publickey
debug1: Trying private key: /home/user/.ssh/id_ed25519
debug1: No more authentication methods to try.
Permission denied (publickey).

但是,當我從另一個 IP 地址(例如 10.24.25.29)嘗試相同的操作時,我可以成功連接。

我需要從同一主機執行 gerrit 和 jenkins。感謝有關調試此問題的幫助。

伺服器不接受您的任何密鑰。檢查您是否已授權伺服器上的一個或多個 ssh 密鑰。

此外,您不能使用 DSA 密鑰id_dsa,因為伺服器不接受這種密鑰類型。它必須是其他密鑰類型之一。

引用自:https://serverfault.com/questions/1025246