具有非默认端口的 gitolite
要克隆由 gitolite 管理的存储库,通常使用以下语法。
git clone gitolite@server:repository
这告诉 SSH 客户端使用 gitolite 作为用户名连接到服务器的端口 22。当我使用端口号尝试时:
git clone gitolite@server:22:repository
Git 抱怨存储库 22:repository 不可用。如果 SSH 服务器使用不同的端口,应使用什么语法?
To clone a repository managed by gitolite one usually uses following syntax
git clone gitolite@server:repository
This tells the SSH client to connect to port 22 of server using gitolite as user name. When I try it with the port number:
git clone gitolite@server:22:repository
Git complains that the repository 22:repository is not available. What syntax should be used if the SSH server uses a different port?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
“SCP 风格”Git URL 语法 (
user@server:path
) 不支持包含端口。要包含端口,您必须使用ssh://
“Git URL”。例如:注意:与
gitolite@server:repository
相比,这向远程端提供了稍微不同的存储库路径(绝对/repository
而不是相对路径 <代码>存储库); Gitolite 接受两种类型的路径,其他系统可能会有所不同。另一种方法是在
~/.ssh/config
中使用Host
条目(请参阅您的 ssh_config(5) 手册页)。使用这样的条目,您可以创建一个“SSH 主机昵称”,其中包含服务器名称/地址、远程用户名和非默认端口号(以及您可能喜欢的任何其他 SSH 选项):然后您可以使用非常简单的 Git URL,例如
gitolite:repository
。如果您必须为多人记录(和/或配置)此内容,我会使用
ssh://
URL,因为不涉及额外的配置。如果这仅适合您(特别是如果您最终可能从同一服务器访问多个存储库),那么使用 SSH 主机昵称来节省一些打字可能会更好。
The “SCP style” Git URL syntax (
user@server:path
) does not support including a port. To include a port, you must use anssh://
“Git URL”. For example:Note: As compared to
gitolite@server:repository
, this presents a slightly different repository path to the remote end (the absolute/repository
instead of the relative pathrepository
); Gitolite accepts both types of paths, other systems may vary.An alternative is to use a
Host
entry in your~/.ssh/config
(see your ssh_config(5) manpage). With such an entry, you can create an “SSH host nickname” that incorporates the server name/address, the remote user name, and the non-default port number (as well as any other SSH options you might like):Then you can use very simple Git URLs like
gitolite:repository
.If you have to document (and or configure) this for multiple people, I would go with
ssh://
URLs, since there is no extra configuration involved.If this is just for you (especially if you might end up accessing multiple repositories from the same server), it might be nice to have the SSH host nickname to save some typing.
这里有非常详细的解释: https://github .com/sitaramc/gitolite/blob/pu/doc/ssh-troubleshooting.mkd#_appendix_4_host_aliases
使用~/.ssh/config 中的“主机”段落可以让您很好地将所有这些封装在 ssh 中,并为其指定一个简短、易于记忆的名称。示例:
现在您可以简单地使用一个单词 gitolite (这是我们在此处定义的主机别名),ssh 将推断其下定义的所有详细信息 - 只需说 ssh gitolite 和 git clone gitolite:reponame 就可以了。
It is explained in great detail here: https://github.com/sitaramc/gitolite/blob/pu/doc/ssh-troubleshooting.mkd#_appendix_4_host_aliases
Using a "host" para in ~/.ssh/config lets you nicely encapsulate all this within ssh and give it a short, easy-to-remember, name. Example:
Now you can simply use the one word gitolite (which is the host alias we defined here) and ssh will infer all those details defined under it -- just say ssh gitolite and git clone gitolite:reponame and things will work.