magit seems to open a new ssh connection for every command. This becomes very annoying especially when staging more chunks, which takes noticeable time to establish the connection for each chunk.
(from shell, I have persistent ssh connections enabled via ./ssh/config)
I am not sure whether this is a magit or a tramp thing.
But my question is:
How can I make magit re-use the ssh-connection?
EDIT:
The client is
(add-to-list 'tramp-remote-path 'tramp-own-remote-path)
(setq tramp-default-method "ssh")
(setq tramp-inline-compress-start-size 1000000)
## generally re-use existing connections
Host *
ControlMaster auto
ControlPath ~/.ssh/sockets/%r@%h-%p
ControlPersist 600
Host myhost1
HostName 111.11.11.1
User myuser
ForwardX11 yes
ForwardX11Timeout 596h
IdentityFile ~/.ssh/id_rsa
IdentitiesOnly yes
ForwardAgent yes
SendEnv LC_*
ServerAliveInterval 300
The server is RHEL 7.6 (Maipo)
By default Tramp doesn't use the ControlMaster options defined in your SSH config file (see the Tramp FAQ):
Tramp overwrites ControlPath settings when initiating ssh sessions. Tramp does this to fend off a stall if a master session opened outside the Emacs session is no longer open.
The FAQ also shows how to configure the ControlMaster options for TRAMP:
(customize-set-variable
'tramp-ssh-controlmaster-options
(concat
"-o ControlPath=/tmp/ssh-ControlPath-%%r@%%h:%%p "
"-o ControlMaster=auto -o ControlPersist=yes"))
Alternatively, if you want to tell Tramp to use the customisations in your ~/.ssh/config
file you need to change the tramp-use-ssh-controlmaster-options
variable:
(customize-set-variable 'tramp-use-ssh-controlmaster-options nil)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With