带有 -Y 的 ssh 会导致“shell-init:检索当前目录时出错:getcwd:无法访问父目录...”

带有 -Y 的 ssh 会导致“shell-init:检索当前目录时出错:getcwd:无法访问父目录...”

我从我的普通帐户运行了一个 X 应用程序 sudo,使用:

mylappy$ ssh -Y [email protected]
    [email protected]'s password:
[me@myhost ~]$ sudo su - 
[root@myhost ~]# su - me -c 'xauth list' |\
     grep `echo $DISPLAY |\
         cut -d ':' -f 2 |\
         cut -d '.' -f 1 |\
         sed -e s/^/:/`  |\
     xargs -n 3 xauth add

现在,每当我尝试使用 -Y 标志进行 ssh 登录时,都会收到此错误。

mylappy$ ssh -Y [email protected]
[email protected]'s password: 
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
                                                                                                                   shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
                                                        shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
                                                                                                                                                                           Last login: Fri Apr 17 17:43:14 2015 from my.isp.com

显然,以 root 身份运行此应用程序会在某个地方写入一些后续 ssh 会话无法me执行的内容,因为它与 root 相关。

我清理了 ~/.gnome 以及 ~ 中任何看起来可疑的内容。核爆.Xauthority。

我尝试运行 /etc/profile、/etc/bashrc、~/.bashrc、~/.bash_profile 以查看是否有任何内容引发此错误。没有。

[me@myhost ~]$ . /etc/profile           
[me@myhost ~]$ . /etc/bashrc
[me@myhost ~]$ . ~/.bash_profile 
[me@myhost ~]$ . ~/.bashrc

ssh -Y 还会在哪里执行可能引发此错误的操作?

请注意,如果没有 -Y 标志,则不会发生这种情况。

答案1

来自 sshd 联机帮助页:

如果 ~/.ssh/rc 存在并且设置了 sshd_config(5) PermitUserRC 选项,则运行它;否则如果 /etc/ssh/sshrc 存在,则运行它;否则运行 xauth。 “rc”文件在标准输入中被赋予 X11 身份验证协议和 cookie。请参阅下面的 SSHRC。

相关内容