2017-09-23 106 views
0

我在我的ubuntu工作站上生成了ssh_rsa & ssh_rsa.pub因此我可以使用ssh访问gitlab。
它的作品,现在我想我的电脑也使用这些键。
所以我复制了从我的ubuntu工作站生成的id_rsa,并通过git-bash将它粘贴到/C/users/myUserName/.ssh/在windows中使用ubuntu rsa密钥

但我的电脑仍然无法连接到gitlab回购,它打印:

$ ssh -v [email protected] -P 22 
OpenSSH_7.1p1, OpenSSL 1.0.2d 9 Jul 2015 
debug1: Reading configuration data /c/Users/<username>/.ssh/config 
debug1: /c/Users/<username>/.ssh/config line 2: Applying options for gitlab.company.com 
debug1: Reading configuration data /etc/ssh/ssh_config 
debug1: Connecting to gitlab.company.com [192.xxx.xxx.x] port 22. 
debug1: Connection established. 
debug1: identity file /c/Users/<username>/.ssh/id_rsa type 1 
debug1: key_load_public: No such file or directory 
debug1: identity file /c/Users/<username>/.ssh/id_rsa-cert type -1 
debug1: key_load_public: No such file or directory 
debug1: identity file /c/Users/<username>/.ssh/id_dsa type -1 
debug1: key_load_public: No such file or directory 
debug1: identity file /c/Users/<username>/.ssh/id_dsa-cert type -1 
debug1: key_load_public: No such file or directory 
debug1: identity file /c/Users/<username>/.ssh/id_ecdsa type -1 
debug1: key_load_public: No such file or directory 
debug1: identity file /c/Users/<username>/.ssh/id_ecdsa-cert type -1 
debug1: key_load_public: No such file or directory 
debug1: identity file /c/Users/<username>/.ssh/id_ed25519 type -1 
debug1: key_load_public: No such file or directory 
debug1: identity file /c/Users/<username>/.ssh/id_ed25519-cert type -1 
debug1: Enabling compatibility mode for protocol 2.0 
debug1: Local version string SSH-2.0-OpenSSH_7.1 
ssh_exchange_identification: read: Connection reset by peer 

回答

0

默认情况下,ssh将寻找.ssh/id_rsa(.pub)ssh_rsa

因此,首先尝试将这些密钥(私有和公共)重命名为默认名称。

并确保公钥(复制在%USERPROFILE%\.ssh\id_rsa.pub)已被复制为一行行。

注意:您需要复制私钥公钥。

或者至少为您复制的私钥id_rsa生成公钥。

cd %USERPROFILE%\.ssh 
ssh-keygen -y -f id_rsa > id_rsa.pub 

确保Git的路径添加到您的%PATH%

> where ssh-keygen 
D:\prgs\git\latest\usr\bin\ssh-keygen.exe