linux - 将 Windows SSH 连接到 CentOS 7 for git

标签 linux git ssh centos7

我有以下问题,我已经安装了 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/

相关文章:

linux - 根据哈希复制目录中的所有唯一文件

python - 在部署的 Azure 虚拟机启动时运行自定义脚本

linux - 理解 if 中大括号和圆括号的使用

node.js - GitLab CI 使用 Node 测试 master 和 branch 之间的差异

macos - 警告 : Your version of git is 1. 9.3。存在严重的安全漏洞

shell - 需要查看24小时内哪些文件已更改并发送电子邮件(Shell脚本)

android - 仅将新文件(照片)从 Android adb 拉到 linux 操作系统

git - 无法使用 Git 存储更改

linux - scp作为后台工作?

python - 使用远程机器(类似于代理)通过 JupyterLab 打开网站