ssh 配置在家里工作,但不能从另一个目录工作 [英] ssh config is working from home, but not working from another directory

查看:36
本文介绍了ssh 配置在家里工作,但不能从另一个目录工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以解决我的问题,但我很好奇为什么它没有按应有的方式工作.

I could solve my problem, but I'm pretty curious why it isn't working the way it should be.

问题:
~/.ssh/config 中有一个条目:

The problem:
In ~/.ssh/config there is an entry:

Host git
HostName git.myserver.com
User gitolite
Identityfile gitolite

之后在我的主目录中运行:ssh git 它返回此文本(这是正常的事情):

After that in my home directory when I run: ssh git it returns this text (which is a normal thing):

PTY allocation request failed on channel 0

hello myname, this is gitolite@myserver.com running gitolite3 v3.4-3-g797a81f on git 1.7.2.5

 R W    myrepo1
 R W    myrepo2
 R W    .
 R W    .
 R W    .
Connection to git.myserver.com closed.

但是当我从我的 /opt/poky 目录运行 ssh git 时,它无法用我的文件验证我的身份......或者我不知道是什么问题,但结果是:

But when I'm running ssh git from my /opt/poky directory, it cannot authenticate me with my file... or I don't know what's the problem, but the result is:

gitolite@myserver.com's password:

最有趣的是当我将 .git/config's url 变量从 git:poky 更改为 gitolite@git.myserver.com:poky 然后一切正常.

Most interesting is when I'm changing my .git/config's url variable from git:poky to gitolite@git.myserver.com:poky then everything works fine.

这似乎更像是 ssh 问题而不是 gitolite.

It seems more an ssh issue than a gitolite.

会不会是环境变量?

推荐答案

您的配置文件应该包含您的私钥/公钥的完整路径:

Your config file should contain, to be sure, the full path of your private/public key:

Identityfile /path/to/gitolite

除此之外,请确保 $HOME 在两种情况下都相同,并且您使用相同的用户 ID 运行这些命令,以排除任何正确的访问权限.

Beside that, make sure $HOME is the same in both cases, and that you are running those commands with the same user id, to rule out any right access.

最有趣的是当我将 .git/config's url 变量从 git:poky 更改为 gitolite@git.myserver.com:poky 然后一切正常.

Most interesting is when I'm changing my .git/config's url variable from git:poky to gitolite@git.myserver.com:poky then everything works fine.

这意味着您的公钥/私钥(名为 ~/.ssh/gitolite(.pub))被复制为 ~/.ssh/id_rsa(.pub),这是这些键的默认名称,由 ssh 搜索.

That means your public/private key (named ~/.ssh/gitolite(.pub)) is duplicated as ~/.ssh/id_rsa(.pub), which is the default name for those keys, as searched by ssh.

这篇关于ssh 配置在家里工作,但不能从另一个目录工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆