我想从已与服务器打开反向隧道的计算机发送文件。反向隧道将计算机上的端口 22 与服务器上的端口 2222 连接:
autossh -M 0 -q -f -N -o "ServerAliveInterval 120" -o "ServerAliveCountMax 1" -R 2222:localhost:22 [email protected] /cdn-cgi/l/email-protection
If I do:
scp file [email protected] /cdn-cgi/l/email-protection:.
然后 SCP 通过 SSH 发送带有新登录名的文件,在我的例子中使用公钥/私钥。
但如果我这样做:
scp -P 2222 file userserver@localhost:.
我收到“连接被拒绝”消息。如果我更换也会发生同样的情况2222
上面找到的端口是:
netstat | grep ssh | grep ESTABLISHED
如何在不打开新的 ssh 连接(无需握手)的情况下发送文件?
您可以使用ControlMaster
选项在你的ssh_config
(~/.ssh/config
),这将为进一步的 ssh/scp/sftp 会话创建持久连接。这很简单:
Host yourhost
Hostname fqdn.tld
Port port_number # if required, but probably yes, if you do port-forwarding
ControlMaster auto
ControlPath ~/.ssh/master-%r@%h
ControlPersist 5m
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)