Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
git错误“;无法在passwd文件中查找当前用户:没有这样的用户";-这是什么意思?_Git_Ssh_Git Push - Fatal编程技术网

git错误“;无法在passwd文件中查找当前用户:没有这样的用户";-这是什么意思?

git错误“;无法在passwd文件中查找当前用户:没有这样的用户";-这是什么意思?,git,ssh,git-push,Git,Ssh,Git Push,我将git repo克隆到一个远程服务器,使用ssh与之通信。使用git fetch remote可以工作,但当我键入git push remote时,我得到以下输出: Counting objects: 242, done. Delta compression using up to 4 threads. Compressing objects: 100% (184/184), done. Writing objects: 100% (215/215), 238.00 KiB | 0 byte

我将git repo克隆到一个远程服务器,使用ssh与之通信。使用
git fetch remote
可以工作,但当我键入
git push remote
时,我得到以下输出:

Counting objects: 242, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (184/184), done.
Writing objects: 100% (215/215), 238.00 KiB | 0 bytes/s, done.
Total 215 (delta 58), reused 0 (delta 0)
fatal: unable to look up current user in the passwd file: no such user
fatal: The remote end hung up unexpectedly
fatal: The remote end hung up unexpectedly

我的服务器管理员说我的ssh用户是在chroot内部配置的。如何解决此错误?

此错误消息由以下人员返回:

struct passwd*xgetpwuid\u self(无效)
{
结构passwd*pw;
errno=0;
pw=getpwuid(getuid());
如果(!pw)
die(uxd(“无法在passwd文件中查找当前用户:%s”),
errno?strerror(errno):(无此类用户);
返回pw;
}
这意味着函数在/etc/passwd中找不到用于调用git进程的用户帐户的密码条目

这就好像客户不知道如何解决某些服务

请管理员再次检查帐户目录(我们称之为
$D
),如中所示。尤其是它的
$D/etc
文件夹:

cp -fv /etc/{group,prelink.cache,services,adjtime,shells,gshadow,shadow,hosts.deny,localtime,nsswitch.conf,nscd.conf,prelink.conf,protocols,hosts,passwd,ld.so.cache,ld.so.conf,resolv.conf,host.conf} $D/et
事实证明,这在2.6.5中是“固定的”——许多git操作不再需要正确的标识

会议的要点是:

标识:在非严格模式下松开GetpUID错误

如果用户没有指定身份,我们必须求助于 getpwuid()若要查找用户名或gecos字段,我们将立即死亡 当getpwuid失败时(例如,因为用户不存在)。这是 对于提交,我们已经将IDENT_设置为STRICT,并且希望 以假输入为准

但是对于像reflog这样的东西,ident是“尽力”,它 可能是疼痛。例如,即使运行带有 不在/etc/passwd中会导致git呕吐,因为我们不能 查找要放入reflog的标识

我们不必死在xgetpwuid_self中,而是可以返回一个回退 值,并设置“伪”标志。对于电子邮件中的用户名,我们 已经有一个“默认邮件是假的”标志。对于名称字段,我们 引入(并检查)匹配的“默认名称”标志。作为一个 另外,这意味着你现在可以得到通常的“告诉我你是谁”的建议 而不仅仅是“没有这样的用户”的错误

新措施现实施如下:

static struct passwd *xgetpwuid_self(int *is_bogus)
{
    struct passwd *pw;

    errno = 0;
    pw = getpwuid(getuid());
    if (!pw) {
        static struct passwd fallback;
        fallback.pw_name = "unknown";
#ifndef NO_GECOS_IN_PWENT
        fallback.pw_gecos = "Unknown";
#endif
        pw = &fallback;
        if (is_bogus)
            *is_bogus = 1;
    }
    return pw;
}

问题是git无法识别您的身份。这是因为主目录中缺少.gitconfig文件。(只需执行ls-la~以验证它是否丢失)

修正:


这将生成该文件并解决错误。

谢谢您的回答。管理员已经做了所有这些,但仍然不起作用。是否有任何日志文件告诉我需要哪个用户,以便他可以将此用户放入/etc/passwd?@C.S。在客户端,您可以在激活跟踪的情况下进行推送,以获得更多线索:
GIT\u trace=1 GIT推送
。在服务器端,这取决于远程服务器使用的url:https或ssh。但是查看相关服务器(Apache或sshd)的日志也会有所帮助。此方法用于填充默认用户身份,为了避免使用,您可以手动设置身份:
git config--global user.email”you@example.com
git config--global user.name“您的名字”
当我通过远程LDAP对用户进行身份验证时,我遇到了这个问题,因此我在passwd文件中没有条目。我发现我可以通过编辑.git/config文件并将我的用户名@放在有问题的远程服务器的URL字段中的服务器名称之前,而不需要管理员参与(这是一个漫长的过程)。
git config --global user.name "FIRST_NAME LAST_NAME" 
git config --global user.email "OUR_NAME@example.com"