问题原文
原帖链接 · jeb · CC BY-SA 3.0
I have in my ~/.ssh/config file entries with local forward definitions like
HOST myServer
hostname 10.10.0.1
user xyz
LocalForward 8080 localhost:80
LocalForward 4000 127.0.0.1:4000
...
This works like a charm, but I also have scripts to synchronize some data.
These scripts show many warnings when they try to connect to the server while there is already a connection.
bind: Address already in use
channel_setup_fwd_listener_tcpip: cannot listen to port: 8080
bind: Address already in use
channel_setup_fwd_listener_tcpip: cannot listen to port: 4000
....
Is there a neat way to use ssh or rsync with an option to disable all local forwards for a session?
Obviously I could copy&paste each config block and build one with and one without local forwards, but I hope there is a better solution.
已采纳解答
原帖链接 · Jakuje · CC BY-SA 4.0
There is ClearAllForwardings option in ssh_config, which does exactly what you need:
ClearAllForwardings
Specifies that all local, remote, and dynamic port forwardings specified in the configuration files or on the command line be cleared. This option is primarily useful when used from the ssh(1) command line to clear port forwardings set in configuration files, and is automatically set by scp(1) and sftp(1). The argument must be yes or no (the default).
You can use it as a commandline option:
ssh -o ClearAllForwardings=yes host
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
