ssh 不是首先从用户配置文件中读取,而是从系统范围的配置中读取。
这是我的 ssh 详细跟踪(使用本地用户而不是 root 时):
-bash-4.1$ ssh -v srg-b@github.com
OpenSSH_5.3p1, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to github.com [192.30.253.113] port 22.
debug1: Connection established.
debug1: identity file /var/www/html/.ssh/identity type -1
debug1: identity file /var/www/html/.ssh/identity-cert type -1
debug1: identity file /var/www/html/.ssh/id_rsa type -1
debug1: identity file /var/www/html/.ssh/id_rsa-cert type -1
debug1: identity file /var/www/html/.ssh/id_dsa type -1
debug1: identity file /var/www/html/.ssh/id_dsa-cert type -1
debug1: identity file /var/www/html/.ssh/id_ecdsa type -1
debug1: identity file /var/www/html/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version libssh-0.7.0
debug1: no match: libssh-0.7.0
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.3
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-sha1 none
debug1: kex: client->server aes128-ctr hmac-sha1 none
debug1: sending SSH2_MSG_KEXDH_INIT
debug1: expecting SSH2_MSG_KEXDH_REPLY
The authenticity of host 'github.com (192.30.253.113)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.253.113' (RSA) to the list of known hosts.
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /var/www/html/.ssh/identity
debug1: Trying private key: /var/www/html/.ssh/id_rsa
debug1: Trying private key: /var/www/html/.ssh/id_dsa
debug1: Trying private key: /var/www/html/.ssh/id_ecdsa
debug1: No more authentication methods to try.
Permission denied (publickey).
Run Code Online (Sandbox Code Playgroud)
因此,它无法找到我的密钥,其位置是在本地配置中指定的。为什么 ssh 忽略位于 的本地配置文件~/.ssh/config?该文件有 rwe 规则 600 。我也尝试过mod 400,但没有成功。
确保~/.ssh/config 的所有者与您登录时使用的用户名匹配。从上面的捕获来看,您似乎已经登录,因此您应该从 root shellwww-data执行操作。chown www-data:www-data /var/www/html/.ssh/config
请注意,如果 Apache 指出,将 SSH 密钥放在 Apache 可能接触到的任何地方是/var/www/html一件极其糟糕的事情,因为简单的错误配置或 PHP 应用程序利用/错误配置可能会将您的密钥泄露给任何可以访问 Apache 的人。您应该将用户的主目录更改www-data为 Apache 可以访问的任何目录之外的目录。您可以通过在其他地方手动创建目录(例如/etc/systemhome/www-data,创建一个/home/www-data)来编辑 的www-data条目来完成此操作/etc/passwd,您需要注销并重新登录才能使更改生效。
| 归档时间: |
|
| 查看次数: |
15919 次 |
| 最近记录: |