为什么我可以clone却没有权限scp

126 views
Skip to first unread message

Shouchun Wu

unread,
Jul 21, 2011, 4:10:50 AM7/21/11
to GotGit, worldhe...@gmail.com


lihai@william-desktop:~$ git clone ssh://10.18.130.23:29418/forserver.git
Initialized empty Git repository in /home/lihai/forserver/.git/
warning: You appear to have cloned an empty repository.
lihai@william-desktop:~$ ls
examples.desktop forserver hello project
lihai@william-desktop:~$ cd forserver/
lihai@william-desktop:~/forserver$ ls
lihai@william-desktop:~/forserver$ scp -P 29418 -p
gotg...@10.18.130.23:/hooks/commit-msg .git/hooks/
Permission denied (publickey).

Larry Cai

unread,
Jul 21, 2011, 4:15:51 AM7/21/11
to got...@googlegroups.com
scp -P 29418 -p lihai@10.18.130.23:/hooks/commit-msg .git/hooks/

再试试

rgs/larry

2011/7/21 Shouchun Wu <wusho...@fruitsmobile.com>

--
您收到这封邮件是因为您订阅了 Google Groups "GotGit" 邮件组。
向邮件组发言很简单,发送邮件到: got...@googlegroups.com 即可。
如果不想继续收到相关邮件,发送退订邮件到 gotgit+un...@googlegroups.com
您也可以通过 Web 界面访问和配置本邮件列表:
http://groups.google.com/group/gotgit?hl=en?hl=en



--
True software development embraces consistent inconsistency.
blog: http://codeslife.com

Shouchun Wu

unread,
Jul 21, 2011, 4:18:34 AM7/21/11
to GotGit
搞定了,多谢

On 7月21日, 下午4时15分, Larry Cai <larry.ca...@gmail.com> wrote:
> scp -P 29418 -p li...@10.18.130.23:/hooks/commit-msg .git/hooks/
>
> 再试试
>
> rgs/larry
>
> 2011/7/21 Shouchun Wu <wushouc...@fruitsmobile.com>
>
>
>
>
>
> > lihai@william-desktop:~$ git clone ssh://10.18.130.23:29418/forserver.git
> > Initialized empty Git repository in /home/lihai/forserver/.git/
> > warning: You appear to have cloned an empty repository.
> > lihai@william-desktop:~$ ls
> > examples.desktop forserver hello project
> > lihai@william-desktop:~$ cd forserver/
> > lihai@william-desktop:~/forserver$ ls
> > lihai@william-desktop:~/forserver$ scp -P 29418 -p
> > gotger...@10.18.130.23:/hooks/commit-msg .git/hooks/

Jiang Xin

unread,
Jul 21, 2011, 4:27:19 AM7/21/11
to GotGit
是怎么搞定的,之前错在哪里了,分享一下吧。 :)

Shouchun Wu

unread,
Jul 21, 2011, 4:51:46 AM7/21/11
to GotGit
按2楼方法 搞定了

Jiang Xin

unread,
Jul 21, 2011, 5:00:45 AM7/21/11
to GotGit
On Jul 21, 4:51 pm, Shouchun Wu <wushouc...@fruitsmobile.com> wrote:
> 按2楼方法 搞定了

我认为不需要在服务器IP地址前加上"用户名@",因为认证采用公钥认证。

scp -P 29418 -p 10.18.130.23:/hooks/commit-msg .git/hooks/

如果不是缺省公钥,用 -i identity_file 参数,或者使用 SSH 主机别名,像第29章介绍的那样。

Larry Cai

unread,
Jul 21, 2011, 5:06:29 AM7/21/11
to got...@googlegroups.com
 缺省不用加 ”用户名@“, 但有时候(极少) $user 是不一样的.

Jiang Xin

unread,
Jul 21, 2011, 5:13:43 AM7/21/11
to GotGit

On Jul 21, 5:06 pm, Larry Cai <larry.ca...@gmail.com> wrote:
> 缺省不用加 "用户名@", 但有时候(极少) $user 是不一样的.
>

如果是 Gitolite 或者是 Gitosis,连接其 ssh 服务,是必须用用户名的,因为 Gitolite
或者 Gitosis 服务是绑定在标准 SSH 服务器下的某一个用户,如 git 或者 gitosis?

但是 Gerrit 开启在 29418 端口的 SSH 服务,是否设定用户名,晚上我实验一下再报告。

Jiang Xin

unread,
Jul 21, 2011, 10:35:52 PM7/21/11
to GotGit
的确,Gerrit 的 SSH 服务需要指定用户名,该用户名就是 Gerrit 账号ID,并使用该用户注册的公钥。
如果误打误撞,貌似可以使用,是因为缺省 Gerrit 授权匿名用户可读。

本书第五篇是最先完成的部分,那时都在 Debian 一个系统下,没有使用虚拟机。改版时要遵照 Larry
的意见,架设多个虚拟机并为不同虚拟机编号(易为识别的名称),而不再以本机 localhost 作为服务器。

Larry Cai

unread,
Jul 21, 2011, 10:48:50 PM7/21/11
to got...@googlegroups.com
我想 gerrit 基于ssh 它会用 $user 作为缺省用户访问,一般还是不用指定的。

举个列子,为了偷懒,不给jenkins一个特别用户,但是他的启动用户是 tomcat怎么办呢。

拷贝 ~larrycai/.ssh/id_rsa 到 ~tomcat/.ssh, 然后在tomcat用户也可以访问 gerrit。
$ ssh larrycai@gerritserver:29581/abc.git

这是ssh的概念,和gerrit应该无关。

不知道这样解释对不对。

rgs/larry

2011/7/22 Jiang Xin <worldhello.net@gmail.com>
--
您收到这封邮件是因为您订阅了 Google Groups "GotGit" 邮件组。
向邮件组发言很简单,发送邮件到: got...@googlegroups.com 即可。
如果不想继续收到相关邮件,发送退订邮件到 gotgit+un...@googlegroups.com
您也可以通过 Web 界面访问和配置本邮件列表:
http://groups.google.com/group/gotgit?hl=en?hl=en

Jiang Xin

unread,
Jul 21, 2011, 11:18:05 PM7/21/11
to GotGit
> $ ssh larrycai@gerritserver:29581/abc.git
> 这是ssh的概念,和gerrit应该无关。

缺省的 29418 端口或者你设置的 29581 端口,是SSH服务器端口,但是这个SSH服务器是由 Gerrit 控制的,是Java语言实现
的。
应该说是 SSH 概念,但是和 Gerrit 也相关。这个特殊端口的 SSH 服务所包含的可登录用户,来自于 Gerrit 中注册的用户账
号。

我在 Gerrit 中创建了四个账号: jiangxin(管理员), dev1, dev2, dev3.
四个用户的私钥分别是 ~/.ssh/jiangxin, ~/.ssh/dev1, ~/.ssh/dev2, ~/.ssh/dev3
更改 Gerrit 授权,匿名用户不可读。

下面的命令可以看出只有 Gerrit 的 SSH 服务的登录ID和公钥文件一致,才能正确登录。

$ ssh -p 29418 -i ~/.ssh/jiangxin jian...@192.168.99.20 gerrit ls-
projects > /dev/null; echo $?
0
$ ssh -p 29418 -i ~/.ssh/dev1 jian...@192.168.99.20 gerrit ls-
projects > /dev/null; echo $?
Permission denied (publickey).
255
$ ssh -p 29418 -i ~/.ssh/dev1 de...@192.168.99.20 gerrit ls-projects > /
dev/null; echo $?
0
$ ssh -p 29418 -i ~/.ssh/dev2 de...@192.168.99.20 gerrit ls-projects > /
dev/null; echo $?
Permission denied (publickey).
255
$ ssh -p 29418 -i ~/.ssh/dev2 de...@192.168.99.20 gerrit ls-projects > /
dev/null; echo $?
0


On Jul 22, 10:48 am, Larry Cai <larry.ca...@gmail.com> wrote:
> 我想 gerrit 基于ssh 它会用 $user 作为缺省用户访问,一般还是不用指定的。
>

的确,一般情况下用户在 Gerrit 的注册ID和自己本机账户一致,注册公钥也是缺省公钥,因此无需指定 Gerrit 的登录ID。

Reply all
Reply to author
Forward
0 new messages