Ste*_*ett 17 ssh rhel configuration tty
我正在尝试通过没有 nc 的服务器设置自动 SSH 跳转。
这从命令行工作:
ssh -A gateway ssh steve@target
Run Code Online (Sandbox Code Playgroud)
(我已将我的公钥添加到 SSH 代理中)。
但是,将其添加到 ~/.ssh/config 不会:
Host target
User steveb
ProxyCommand ssh -A gateway ssh steve@targetip
$ ssh target
Pseudo-terminal will not be allocated because stdin is not a terminal.
^CKilled by signal 2.
Run Code Online (Sandbox Code Playgroud)
试图强行解决问题-t
很有趣但无济于事。
ProxyCommand ssh -A -t gateway ssh steve@targetip
$ ssh target
Pseudo-terminal will not be allocated because stdin is not a terminal.
Pseudo-terminal will not be allocated because stdin is not a terminal.
^CKilled by signal 2.
Run Code Online (Sandbox Code Playgroud)
更多-t
的?不好。
ProxyCommand ssh -A -t -t gateway ssh steve@targetip
$ ssh target
tcgetattr: Inappropriate ioctl for device
^CKilled by signal 2.
Run Code Online (Sandbox Code Playgroud)
这可能吗?大多数教程(例如http://www.arrfab.net/blog/?p=246)建议使用nc
.
Mou*_*inX 14
当主机只能间接访问时,ProxyCommand 非常有用。使用 netcat 是相对困难的:
ProxyCommand ssh {gw} netcat -w 1 {host} 22
Run Code Online (Sandbox Code Playgroud)
这里 {gw } 和 {host} 是网关和主机的占位符。
但是当网关上没有安装netcat时也是可以的:
ProxyCommand ssh {gw} 'exec 3<>/dev/tcp/{host}/22; cat <&3 & cat >&3;kill $!'
Run Code Online (Sandbox Code Playgroud)
/dev/tcp 是标准 bash 的内置功能。文件不存在。要检查 bash 是否内置了此功能,请运行:
cat < /dev/tcp/google.com/80
Run Code Online (Sandbox Code Playgroud)
...在网关上。
要确保使用 bash,请使用:
ProxyCommand ssh {gw} "/bin/bash -c 'exec 3<>/dev/tcp/{host}/22; cat <&3 & cat >&3;kill $!'"
Run Code Online (Sandbox Code Playgroud)
它甚至可以与 ControlMaster 一起使用。
(10 月 22 日更新,包括 kill 以清理背景猫)(2011 年 3 月 3 日更新以使占位符更清晰并解释 /dev/tcp)
100% 归功于罗兰·舒尔茨。这是来源:
http :
//www.rschulz.eu/2008/09/ssh-proxycommand-without-netcat.html 在那里的评论中看到更多有用的信息。
这里还有更多:
http : //www.linuxjournal.com/content/tech-tip-tcpip-access-using-bash
http://securityreliks.securegossip.com/2010/08/enabling-devtcp-on-backtrack -4r1ubuntu/
更新:这是Marco 的新消息
参考 ~/.ssh/config 中的 ProxyCommand ,其中有这样一行:
ProxyCommand ssh gateway nc localhost %p
Run Code Online (Sandbox Code Playgroud)
马尔科 说:
如果您使用最新版本的 OpenSSH,则不需要 netcat。您可以将 nc localhost %p 替换为 -W localhost:%p。
结果如下所示:
ProxyCommand ssh gateway -W localhost:%p
Run Code Online (Sandbox Code Playgroud)
小智 9
大T,不是小T。
-T' Disable pseudo-tty allocation.
-t' Force pseudo-tty allocation.
Run Code Online (Sandbox Code Playgroud)
我的脚本曾经返回该消息,现在不再返回。
/usr/bin/ssh -T -q -i $HOME/.ssh/one_command other_system
Run Code Online (Sandbox Code Playgroud)
我使用authorized_key
other_system 上的 来使其运行命令:
from="my.mydomain.com",command="bin/remotely-run" ssh-rsa ...
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
67447 次 |
最近记录: |