git 使用 ssh 时出现错误:权限被拒绝(公钥,键盘交互)

git 使用 ssh 时出现错误:权限被拒绝(公钥,键盘交互)

我正在尝试使用 windows 远程构建 git repo 服务器。这是我的 ssh 服务器和本地客户端构建环境:

服务器环境
1. windows 操作系统
2. mysysgit 安装
3. copssh 安装
4. 远程云服务器

客户
1. vmware 上的 centOS 7
2. 本地电脑

以下是我已经采取的措施。 1.在我的 centos 客户端上

生成一个公钥-私钥对 2. 添加一个名为ssh-keygen -t rsa
svccopssh在我的远程windows服务器上
3.将我的centos复制~/.ssh/id_rsa.pub到服务器文件夹d:/Users/svccopssh/.ssh,其中copssh读取public-ssh-key,然后重命名为authorized_keys
4.运行测试:
ssh -vT svccopssh@remoteIP

结果出来是这样的:

[is_january@localhost .ssh]$ ssh -vT [email protected]
OpenSSH_6.6.1, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 56: Applying options for *
debug1: Connecting to 120.76.123.231 [120.76.123.231] port 22.
debug1: Connection established.
debug1: identity file /home/is_january/.ssh/id_rsa type 1
debug1: identity file /home/is_january/.ssh/id_rsa-cert type -1
debug1: identity file /home/is_january/.ssh/id_dsa type -1
debug1: identity file /home/is_january/.ssh/id_dsa-cert type -1
debug1: identity file /home/is_january/.ssh/id_ecdsa type -1
debug1: identity file /home/is_january/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/is_january/.ssh/id_ed25519 type -1
debug1: identity file /home/is_january/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.1
debug1: match: OpenSSH_7.1 pat OpenSSH* compat 0x04000000
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr [email protected] none
debug1: kex: client->server aes128-ctr [email protected] none
debug1: kex: [email protected] need=20 dh_need=20
debug1: kex: [email protected] need=20 dh_need=20
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDS 26:95:35:2c:32:ad:46:14:94:5e:71:95:b7:f7:2d:aa
debug1: Host '120.76.123.231' is known and matches the ECDSA host key.
debug1: Found key in /home/is_january/.ssh/known_hosts:1
debug1: ssh_ecdsa_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,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/is_january/.ssh/id_rsa
debug1: Authentications that can continue: publickey,keyboard-interactive
debug1: Trying private key: /home/is_january/.ssh/id_dsa
debug1: Trying private key: /home/is_january/.ssh/id_ecdsa
debug1: Trying private key: /home/is_january/.ssh/id_ed25519
debug1: Next authentication method: keyboard-interactive
debug1: Authentications that can continue: publickey,keyboard-interactive
debug1: No more authentication methods to try.
Permission denied (publickey,keyboard-interactive).

有什么建议吗?我确信相同的公钥在 github ssh-key 上也能很好地工作

答案1

嗯,实际上,我已经知道问题所在并且解决了它。

当我安装 copssh 客户端时,有一个步骤要求我选择用户目录。我使用了自定义配置,即目录d:/Users/svccopssh/.ssh。但是,svccopssh 读取公钥的确切目录是d:/copssh/home/svccopssh/.ssh,显然不是我在安装中使用的目录。在我将 authorized_keys 位置更改为正确位置后:path/to/copssh_loaction/home/yourUserName/.ssh,它就起作用了。

相关内容