【发布时间】:2018-04-22 10:20:33
【问题描述】:
两台安装了 ubuntu 的笔记本电脑。
这些系统上 user1 的 ssh 和 git config 设置相同。
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 = user1
Rsa 私钥/公钥在这些系统中也是相同的
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 clone”
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 .git
user1@system1 尝试“git clone”
响应是 Permission denied (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 clone ssh://system1_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
如何将 user1@system1 的 ssh/git 配置或其他配置更改为在 system1 上“git clone”此存储库?
【问题讨论】:
-
.ssh目录的权限是什么? -
0700和0775分别。显然。这实际上包含在问题中。从这个意义上说,这是我希望看到问题的 system2。不过,config烫发可能太多了。