kal*_*gne 5 ssh bash shell sh x11-forwarding
bash我的 bash 配置文件中有一个特定的代码:
$ cat ~/.bash_profile
#!/usr/bin/env bash
echo "SHELL: $SHELL"
function printfiles() {
while IFS='' read -r _file || [[ -n "$_file" ]]; do
echo "file: ${_file}"
done < <(ls)
} && export -f printfiles
Run Code Online (Sandbox Code Playgroud)
的< <(FUNCTION)是bash特定的语法,不支持的sh。当我使用 ssh 登录到远程机器时:
$ ssh my.remote
me@xxx.xx.xxx.xx's password:
Last login: Fri Nov 17 11:27:39 2017 from yyy.yy.yy.yy
sourcing /home/me/.bash_profile
SHELL: /bin/bash
Run Code Online (Sandbox Code Playgroud)
它工作正常。现在我想再次登录但转发我的X11:
$ ssh -X my.remote
me@xxx.xx.xxx.xx's password:
sh: printfiles: line 2: syntax error near unexpected token `<'
sh: printfiles: line 2: ` done < <(ls)'
sh: error importing function definition for `printfiles'
sh: printfiles: line 2: syntax error near unexpected token `<'
sh: printfiles: line 2: ` done < <(ls)'
sh: error importing function definition for `printfiles'
sh: printfiles: line 2: syntax error near unexpected token `<'
sh: printfiles: line 2: ` done < <(ls)'
sh: error importing function definition for `printfiles'
sh: printfiles: line 2: syntax error near unexpected token `<'
sh: printfiles: line 2: ` done < <(ls)'
sh: error importing function definition for `printfiles'
Last login: Fri Nov 17 11:28:51 2017 from yyy.yy.yy.yy
sourcing /home/me/.bash_profile
SHELL: /bin/bash
Run Code Online (Sandbox Code Playgroud)
我不知道发生了什么,似乎当我以某种方式进行 X11 转发时,shshell 被用于bash. 为什么会这样,如何解决?
如果我发现 -X 和 -x 登录之间不一致,我怀疑:
env -i ssh ...另外:一般来说,我喜欢使用 -x 来解决许多此类问题。您可以在服务器端配置 Shell 以在登录时启用跟踪 (-x)。
如果我想到其他的,我会更新。
| 归档时间: |
|
| 查看次数: |
195 次 |
| 最近记录: |