两台安装了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-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
复制相似问题