Jac*_*cek 5 windows ssh port-forwarding openssh remote-access
我正在尝试在 Windows 上使用 OpenSSH ProxyCommand 通过 device1 连接到 device2。Device2 请求 xxxxx 端口转发和连接,无需 ProxyCommand,工作正常(但需要首先连接到 device1,然后连接到 device2,我想要简单的一步连接)。
我创建了 C:\Program Files\OpenSSH\etc\ssh_config 文件,如下所示:
Host device1
Hostname xxx.xxx.xx.xx
User root
Host device2
ProxyCommand ssh -q device1 nc -q0 localhost xxxxx
Run Code Online (Sandbox Code Playgroud)
现在当我打字时
ssh user@device2
Run Code Online (Sandbox Code Playgroud)
我明白了
/bin/sh: No such file or directory
write: Broken pipe
Run Code Online (Sandbox Code Playgroud)
我已经在 Linux 操作系统上检查过了,它工作得很好。你能解释一下我可能错在哪里吗?
此外,我还尝试在 C:\Program Files\OpenSSH\home\user\.ssh\config 中创建配置并得到相同的结果。
当我删除配置文件时,我得到
ssh: Could not resolve hostname device2: Name or service not known
Run Code Online (Sandbox Code Playgroud)
所以该文件似乎已被检测到。
我使用的是 OpenSSH_7.6p1、OpenSSL 1.0.2k 2017 年 1 月 26 日和 Windows 10
小智 5
ProxyJump
今天我对此进行了斗争,因为我想在 Windows 中使用。问题似乎是 Windows 中的 openssh 可能会调用错误的 ssh,这对我不起作用。
\xce\xbb ssh.exe -v target-via-pj\nOpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5\ndebug1: Reading configuration data C:\\\\Users\\\\nico/.ssh/config\ndebug1: C:\\\\Users\\\\nico/.ssh/config line 41: Applying options for target-via-pj\ndebug1: Setting implicit ProxyCommand from ProxyJump: ssh -v -W '[%h]:%p' my-proxy\ndebug1: Executing proxy command: exec ssh -v -W '[XXX.XXX.XXX.XXX]:22' my-proxy\nCreateProcessW failed error:2\nposix_spawn: No such file or directory\n
Run Code Online (Sandbox Code Playgroud)\n\n对我有用的是显式指定 ProxyCommand。这是我在 Windows 中对代理和目标的定义。
\n\nHost my-proxy\n HostName 192.168.66.22 \n User user \n IdentityFile ~/.ssh/id_rsa\n\nHost target-via-pj\n Hostname XXX.XXX.XXX.XXX \n User user\n ProxyCommand ssh.exe -W %h:%p proxy\n IdentityFile ~/.ssh/id2_rsa \n\n
Run Code Online (Sandbox Code Playgroud)\n\n这导致:
\n\n\xce\xbb ssh.exe -v target-via-pj \nOpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5 \ndebug1: Reading configuration data C:\\\\Users\\\\nico/.ssh/config \ndebug1: C:\\\\Users\\\\nico/.ssh/config line 41: Applying options for target-via-pj \ndebug1: Executing proxy command: exec ssh.exe -W XXX.XXX.XXX.XXX:22 proxy\ndebug1: key_load_public: No such file or directory \ndebug1: identity file C:\\\\Users\\\\nico/.ssh/id_rsa type -1 \ndebug1: key_load_public: No such file or directory \ndebug1: identity file C:\\\\Users\\\\nico/.ssh/id_rsa-cert type -1 \ndebug1: Local version string SSH-2.0-OpenSSH_for_Windows_7.7 \ndebug1: Remote protocol version 2.0, remote software version OpenSSH_7.6p1 Ubuntu-4ubuntu0.3 \ndebug1: match: OpenSSH_7.6p1 Ubuntu-4ubuntu0.3 pat OpenSSH* compat 0x04000000 \ndebug1: Authenticating to XXX.XXX.XXX.XXX:22 as 'user' \n
Run Code Online (Sandbox Code Playgroud)\n\n希望有帮助!
\n好吧,我想我已经弄清楚了,尽管我的问题没有解决,因为它不可能。
从我的研究和感谢https://superuser.com/users/213663/martin-prikryl我了解到,没有构建支持 ProxyCommand 的 Windows 版 OpenSSH(至少我找不到一个,在他们的网站上)就是这样的信息)。
我得到的原因是:
/bin/sh: No such file or directory
write: Broken pipe
Run Code Online (Sandbox Code Playgroud)
是因为 OpenSSH 构建错误。我从下载的
https://sourceforge.net/projects/sshwindows/
根据那里的评论,这个版本已经坏了!请不要使用它!当我卸载这个 OpenSSH 并从网站(或 Windows 10 可选功能)安装官方 OpenSSH 后,我得到了正确的错误:
Proxy connect is not supported in Windows yet
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
22435 次 |
最近记录: |