两台安装了ubuntu的笔记本电脑。
这些系统上user1的ssh和git配置是相同的设置。
cat /home/user1/.ssh/config
Host system1
Hostname <system1_ip>
User user1
IdentityFile ~/.ssh/id_rsa_common
cat /home/user1/.gitconfig
[user]
email = user1@gmail.com
name = user1Rsa私有/公共密钥在这些系统中也是相同的
user1@system1:~/.ssh$ ls -al
total 28
drwx------ 2 user1 user1 4096 Apr 18 00:09 .
drwxr-xr-x 50 user1 user1 4096 Apr 18 00:06 ..
-rw------- 1 user1 user1 408 Feb 18 2017 authorized_keys
-rw-rw-r-- 1 user1 user1 91 Apr 18 00:04 config
-r-------- 1 user1 user1 1675 Feb 24 2017 id_rsa_common
-rw-r--r-- 1 user1 user1 408 Feb 24 2017 id_rsa_common.pub
-rw-r--r-- 1 user1 user1 1550 Apr 12 19:51 known_hosts
user1@system2:~/.ssh$ ls -al
total 24
drwxrwxr-x 2 user1 user1 4096 Apr 17 20:12 .
drwxr-xr-x 21 user1 user1 4096 Apr 17 23:08 ..
-rw-rw-r-- 1 user1 user1 91 Apr 17 20:12 config
-r-------- 1 user1 user1 1675 Apr 17 20:12 id_rsa_common
-rw-r--r-- 1 user1 user1 408 Apr 17 20:12 id_rsa_common.pub
-rw-r--r-- 1 user1 user1 1550 Apr 17 20:12 known_hosts在system1中创建的git存储库。
user1@system2可以正确地进行"git克隆“
user1@system2:~/job/test$ git clone ssh://<system1_ip>/home/git_root/mypicture.git
Cloning into 'mypicture'...
warning: You appear to have cloned an empty repository.
Checking connectivity... done.
orion@ubuntu-pavilion:~/job/test$ ls -al mypicture/
total 12
drwxrwxr-x 3 user1 user1 4096 Apr 18 01:38 .
drwxrwxr-x 3 user1 user1 4096 Apr 18 01:38 ..
drwxrwxr-x 7 user1 user1 4096 Apr 18 01:38 .gituser1@system1尝试"git克隆“
响应是权限被拒绝(publickey)。
user1@system1:~/job/git_test/local/temp$ git clone ssh://<system1_ip>/home/git_root/mypicture.git
Cloning into 'mypicture'...
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.使用以下命令进行调试:
GIT_SSH_COMMAND="ssh -vvv“git克隆ssh://system1 1_ip/home/git_root/mypicture.git
转储的一部分显示找不到私钥:
...
debug1: SSH2_MSG_NEWKEYS received
debug2: key: /home/user1/.ssh/id_rsa ((nil))
debug2: key: /home/user1/.ssh/id_dsa ((nil))
debug2: key: /home/user1/.ssh/id_ecdsa ((nil))
debug2: key: /home/user1/.ssh/id_ed25519 ((nil))
....
debug1: Trying private key: /home/user1/.ssh/id_rsa
debug3: no such identity: /home/user1/.ssh/id_rsa: No such file or directory
debug1: Trying private key: /home/user1/.ssh/id_dsa
debug3: no such identity: /home/user1/.ssh/id_dsa: No such file or directory
debug1: Trying private key: /home/user1/.ssh/id_ecdsa
debug3: no such identity: /home/user1/.ssh/id_ecdsa: No such file or directory
debug1: Trying private key: /home/user1/.ssh/id_ed25519
debug3: no such identity: /home/user1/.ssh/id_ed25519: No such file or directory如何更改ssh/git配置或为user1@system1在system1上"git克隆“此存储库?
发布于 2018-04-18 02:30:27
我大胆地猜测,过于宽松的${HOME}/.ssh/config会使您的ssh失败,试着将其限制在0600上。查看详细的输出,它尝试使用键的默认名称,而不是您指定的~/.ssh/id_rsa_common。
您还可以更正您的系统二上的权限。通常$HOME/.ssh/是0700和config,keys以及known_hosts和authorized_hosts是0600。
然而,这只是一个基于可用信息的猜测。还有一件事让我很头疼(但可能是*buntu特有的),我的ssh会像你的系统上看到的那样,用权限拒绝${HOME}/.ssh/config,但它也会让我知道它在控制台上用Bad owner or permissions on /home/user1/.ssh/config这样做了。
希望这能有所帮助。
发布于 2018-04-18 03:07:27
尝试以下操作:
将密钥添加到ssh:
ssh-add这将添加默认密钥,除非您提供要添加的特定密钥
SSH ssh-add是用于在
认证代理中添加SSH私钥的命令,用于实现与SSH的单点登录。代理进程称为
ssh-agent
请阅读下面的内容,看看如何运行它。
启动/重新启动ssh=agent
eval $(ssh-agent)这将启动ssh代理并打印出servive的PID。
The ssh-agent是一个helper程序,用于跟踪用户的身份密钥及其密码。然后,代理可以使用这些密钥登录到其他服务器,而无需用户再次键入密码或口令短语。
发布于 2018-04-22 10:20:33
根本原因是user1@system1在执行git clone时无法识别ssh://system1_ip。
${HOME}/.ssh/config仅在Host system1中指定密钥,而不在Host system1_ip中指定
所以如果user1@system1应用ssh://system1,它就能正常工作
但到目前为止,我不知道为什么user1@system2可以在ssh://system1_ip的情况下指定密钥。
https://stackoverflow.com/questions/49884550
复制相似问题