yel*_*hil 5 ssh io-redirection
我实际上不需要运行下面的命令,如果我确实想在不输入密码的情况下登录,我知道 ssh 密钥。我只想知道如何ssh
绕过我的文件重定向。
运行以下命令,ssh
提示我输入密码:
ssh nobody@192.168.1.151 > /dev/null 2> /dev/null < /dev/null
Run Code Online (Sandbox Code Playgroud)
这是如何运作的?stdin
、stdout
和stderr
都被重定向,但ssh
仍然设法在我的屏幕上打印提示并阅读我输入的内容。我尝试添加ssh
参数-t -t
和-T
(不是同时添加)以启用或禁用伪 tty 分配,但没有任何区别。
我也尝试以这种方式关闭所有输入和输出,尽管我不知道我是否输入正确。仍然ssh
提示输入密码:
(exec 0<&- 1<&- 2<&- 0>&- 1>&- 2>&-; ssh nobody@192.168.1.151)
Run Code Online (Sandbox Code Playgroud)
小智 6
来自 OpenSSH readpassphrase.c,第 75 行:
/*
* Read and write to /dev/tty if available. If not, read from
* stdin and write to stderr unless a tty is required.
*/
Run Code Online (Sandbox Code Playgroud)
该程序直接读取和写入 TTY,因此无法通过关闭标准输入和输出管道来禁用直接输入。您必须告诉 SSH 客户端使用提供的密码或按照@muru 的建议进行操作。
归档时间: |
|
查看次数: |
2416 次 |
最近记录: |