我有以下问题,我已经安装了 CentOS 7 的服务器。现在我想使用该服务器进行 git。
问题是我无法与服务器建立 SSH 连接来执行此操作。我已经制作了 key ,并将 id_rsa key 放入 C:\Users\MYNAME.ssh
我还在服务器上创建了一个 git 用户并将公钥放在/home/git/.ssh/authorized_keys 中
当我想将存储库克隆到我的服务器时,我使用以下命令:
$ git clone ssh://git@IP/domains/optiekruymen.be/public_html/.git
输出为
Cloning into 'public_html'...
Enter passphrase for key '/c/Users/MYNAME/.ssh/id_rsa':
git@IP's password:
我不明白为什么我仍然需要提供 git 密码,因为我想使用 ssh 连接而不是 git 用户的密码。
我使用 ssh-keygen 在 Centos 上生成了 key ,然后使用复制的 key
cat id_rsa.pub >> /home/git/.ssh/authorized_keys
为了将文件复制到 git 用户,接下来我将 key 下载到我的电脑并将 id_rsa 复制到/c/Users/MYNAME/.ssh/id_rsa
额外输出
.ssh 文件设置
drwx------ 2 git git 4096 Feb 13 20:59 .ssh
authorized_keys 文件设置
-rw-r--r-- 1 git git 408 Feb 13 20:53 authorized_keys
其他调试信息
debug1: Trying private key: /c/Users/USERNAME/.ssh/id_rsa
debug3: sign_and_send_pubkey: RSA
SHA256:xUB8U9Mn3EkwzhLXjsBlZU1tJMViEfM/Yit5Kjkv/TA
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with mic,password
最佳答案
此消息表示您的私钥受密码保护(使用密码加密),在连接到远程主机之前,需要解密此 key (通过您输入密码)。
解决这个问题最简单的方法是remove the passphrase from the private key.
关于linux - 将 Windows SSH 连接到 CentOS 7 for git,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35383571/