Ubuntu

為什麼我無法以 root 身份 ssh?

  • October 14, 2014

我是同一防火牆下的兩台伺服器A和B。我可以使用 root 帳戶從伺服器 A 登錄到 B,但我無法從 B 登錄到 A。我的 ssh 密鑰已正確配置,但我無法弄清楚我們出了什麼問題。

這是我嘗試從伺服器 B 連接到 A 時的詳細資訊。

root@web04:~# ssh -v -i.ssh/id_rsa root@11.11.11.4
OpenSSH_5.9p1 Debian-5ubuntu1.4, OpenSSL 1.0.1 14 Mar 2012
Warning: Identity file .ssh/id_rsa not accessible: No such file or directory.
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to 11.11.11.4 [11.11.11.4] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/id_rsa type -1
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: read_keyfile_line: /root/.ssh/id_dsa.pub line 1 exceeds size limit
debug1: identity file /root/.ssh/id_dsa type -1
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9p1 Debian-5ubuntu1.4
debug1: match: OpenSSH_5.9p1 Debian-5ubuntu1.4 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1.4
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA 2c:37:bc:c8:47:07:53:07:9c:a8:f8:1d:12:a6:4a:a0
debug1: Host '11.11.11.4' is known and matches the ECDSA host key.
debug1: Found key in /root/.ssh/known_hosts:11
debug1: ssh_ecdsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
Ubuntu 12.04 LTS
-------------------------------------
UNAUTHORISED ACCESS IS PROHIBITED!!
-------------------------------------
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Trying private key: /root/.ssh/id_rsa
debug1: Trying private key: /root/.ssh/id_dsa
debug1: read PEM private key done: type DSA
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /root/.ssh/id_ecdsa
debug1: Next authentication method: passwor

請檢查 /etc/ssh/sshd_config 中的“PermitRootLogin”選項是否設置為“yes”。

請注意,這通常設置為“no”或“public-key”,因為通過 SSH 以 root 身份登錄被廣泛認為是一個安全問題。

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