我有一些桥接主机,它允许访问受保护的网络。我使用以下命令连接到它:
ssh sergius@bridge_host -D 3128
因此,我可以在浏览器中打开socks代理并且它可以工作。我可以使用以下命令登录到该网络上的主机:
ssh -o 'ProxyCommand /bin/nc.openbsd -x localhost:3128 %h %p' sergius@any_internal_host
它工作正常,但我无法通过 sshfs 挂载任何这些主机。可能,我不知道如何在 sshfs 命令中使用这个 ssh 选项。我什至尝试过如此愚蠢的技巧:
sshfs -o "ssh_command=\"ssh -o 'ProxyCommand /bin/nc.openbsd -x localhost:3128 %h %p'\"" sergius@$host /home/sergius/work/SSHFS/$host/
sshfs -o 'SSHOPT=ProxyCommand /bin/nc.openbsd -x localhost:3128 %h %p' sergius@$host: /home/sergius/work/SSHFS/$host/
sshfs -o 'port=3128' sergius@$host: /home/sergius/work/SSHFS/$host/
一个命令返回“Connection Reset by Peer”,另一个命令返回未知选项 `SSHOPT=ProxyCommand /bin/nc.openbsd -x localhost:3128 %h %p'
我没能在网上找到任何信息。请帮忙。
===
我觉得自己很愚蠢,但仍然不明白为什么会出现这样的错误:
sshfs -d -o sshfs_debug -o LogLevel=DEBUG3 -o ProxyCommand="/bin/nc.openbsd --proxy localhost:3128 --proxy-type socks5 %h %p" sergius@$host:~ /home/sergius/work/SSHFS/$host/
SSHFS version 2.4
FUSE library version: 2.9.0
nullpath_ok: 0
nopath: 0
utime_omit_ok: 0
executing <ssh> <-x> <-a> <-oClearAllForwardings=yes> <-oLogLevel=DEBUG3> <-oProxyCommand=/bin/nc.openbsd --proxy localhost:3128 --proxy-type socks5 %h %p> <-2> <sergius@dev-host003> <-s> <sftp>
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Executing proxy command: exec /bin/nc.openbsd --proxy localhost:3128 --proxy-type socks5 dev-host003 22
debug1: permanently_drop_suid: 1000
debug1: identity file /home/sergius/.ssh/id_rsa type -1
debug1: identity file /home/sergius/.ssh/id_rsa-cert type -1
debug1: identity file /home/sergius/.ssh/id_dsa type -1
debug1: identity file /home/sergius/.ssh/id_dsa-cert type -1
debug1: identity file /home/sergius/.ssh/id_ecdsa type -1
debug1: identity file /home/sergius/.ssh/id_ecdsa-cert type -1
/bin/nc.openbsd: invalid option -- '-'
usage: nc [-46bCDdhjklnrStUuvZz] [-I length] [-i interval] [-O length]
[-P proxy_username] [-p source_port] [-q seconds] [-s source]
[-T toskeyword] [-V rtable] [-w timeout] [-X proxy_protocol]
[-x proxy_address[:port]] [destination] [port]
ssh_exchange_identification: Connection closed by remote host
read: Connection reset by peer
=================
哇!我设法使它工作!非常感谢您对选项的澄清。我阅读了所有允许的选项并通过“-x proxy_adress[:port]”进行设置:
sshfs -o ProxyCommand="/bin/nc.openbsd -x localhost:3128 %h %p" sergius@$host:/home/sergius /home/sergius/work/SSHFS/$host/
答案1
我曾是回答不久前也有类似的问题。我没有尝试过,但这应该对你有用:
sshfs -o ProxyCommand="/bin/nc.openbsd --proxy localhost:3128 \
--proxy-type socks5 %h %p" sergius@$host: /home/sergius/work/SSHFS/$host/
这SSHOPT=VAL
正是您要使用的选项的格式。您需要将其替换为特定的键值对。
您还需要告诉nc
代理是什么类型