尝试执行以下操作时出现主题错误
$ ssh -T git@github.com
Permission denied (publickey).
.ssh 权限
$ ls -al
total 33
drwxr-xr-x+ 1 MyUser AGL+Group(513) 0 Feb 27 16:53 .
drwxrwxrwt+ 1 MyUser AGL+Group(513) 0 Jan 10 16:12 ..
-rw------- 1 MyUser AGL+Group(513) 1667 Feb 28 18:01 .bash_history
-rwxr-xr-x 1 MyUser AGL+Group(513) 1494 Jan 9 20:45 .bash_profile
-rwxr-xr-x 1 MyUser AGL+Group(513) 6054 Jan 9 20:45 .bashrc
-rw-r--r-- 1 MyUser AGL+Group(513) 55 Feb 27 16:37 .gitconfig
-rwxr-xr-x 1 MyUser AGL+Group(513) 1919 Jan 9 20:45 .inputrc
-rwxr-xr-x 1 MyUser AGL+Group(513) 1236 Jan 9 20:45 .profile
drwx------+ 1 MyUser AGL+Group(513) 0 Feb 28 17:46 .ssh
在此之前,我做了以下步骤
- 生成的 ssh 密钥并存储在 .ssh 文件夹中
检查 ssh 代理
$ ps aux |grep ssh
7236 1 7236 7236 ? 1138370 18:26:09 /usr/bin/ssh-agent通过设置将公钥 id_dsa.pub 添加到 github 帐户
MyUser@PC000009416062 ~/.ssh
$ ssh -v -T git@github.com
OpenSSH_7.1p2, OpenSSL 1.0.2f 28 Jan 2016
debug1: Reading configuration data /etc/ssh_config
debug1: Connecting to github.com [192.30.252.129] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /home/MyUser/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/MyUser/.ssh/id_rsa-cert type -1
debug1: identity file /home/MyUser/.ssh/id_dsa type 2
debug1: key_load_public: No such file or directory
debug1: identity file /home/MyUser/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/MyUser/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/MyUser/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/MyUser/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/MyUser/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.1
debug1: Remote protocol version 2.0, remote software version libssh-0.7.0
debug1: no match: libssh-0.7.0
debug1: Authenticating to github.com:22 as 'git'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client chacha20-poly1305@openssh.com <implicit> none
debug1: kex: client->server chacha20-poly1305@openssh.com <implicit> none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ssh-rsa SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in /home/MyUser/.ssh/known_hosts:2
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: /home/MyUser/.ssh/id_rsa
debug1: Skipping ssh-dss key /home/MyUser/.ssh/id_dsa for not in PubkeyAcceptedKeyTypes
debug1: Trying private key: /home/MyUser/.ssh/id_ecdsa
debug1: Trying private key: /home/MyUser/.ssh/id_ed25519
debug1: No more authentication methods to try.
Permission denied (publickey).
我也尝试了在这个论坛中遵循一些解决方案,但没有运气。我正在使用Cygwin
来执行此操作
解决方案 1
解决方案 2
debug1:跳过 ssh-dss key/home/MyUser/.ssh/id_dsa for not in 公钥接受密钥类型
您生成了dsa
密钥,默认情况下不支持该密钥。您需要添加
PubkeyAcceptedKeyTypes +ssh-dss
到您的~/.ssh/config
,或者更确切地说是生成标准 RSA 密钥,可以正常工作。
因为您似乎使用的是DSA而不是默认的RSA。 您需要添加一行才能在SSH客户端配置中启用它。
以下是我从此链接中检索到的消息
默认情况下,RSA 支持处于打开状态,但 DSA/DSS 支持由以下各项启用:
在 ssh 客户端"配置"文件中添加行。
PubkeyAcceptedKeyTypes ssh-ed25519,ssh-rsa,ssh-dss,ecdsa-sha2
- 将配置文件命名为"config",并将其放在 windows 中的用户主目录/.ssh 中。 /users/myname/.ssh/config
in the current build, the client config file is to be named ssh_config instead of "config"
sshd 服务器端还应sshd_config文件中具有以下条目: PubkeyAcceptKeyTypes ssh-ed25519,ssh-rsa,ssh-dss,ecdsa-sha2 进行这些更改后重新启动 SSH 服务器