7

I often ssh from Windows to the same Linux server and setup SSH tunnels using this server. The authentication is password-based and this is something that is set up by the company policy, so I cannot change that. Providing same password multiple times is a nightmare.

I've read about handling that by keeping SSH connections alive. The recipe was for Linux-to-Linux connection and required updating ~/.ssh/config file

Host *
  ControlPath    ~/.ssh/%C.sock
  ControlMaster  auto
  ControlPersist 10m    

On Windows I can define similar file for OpenSSH. However, when I set it up, I started to get

getsockname failed: Not a socket

I've read ControlPath is not supported on Windows. How can I keep SSH connections alive on Windows?

ᄂ ᄀ
  • 4,187
dzieciou
  • 252

1 Answers1

1

Providing same password multiple times is a nightmare.

In Linux sshpass could help. I don't know if you can use it in Windows. Keep reading.

Workaround: connect exactly one time to an interactive shell, provide the password one time.

  • Port forwardings known in advance may be set up at the time of the connection.

  • Port forwardings can be added or removed interactively later. Use the escape character, by default it's the tilde immediately after Enter. Press Enter~C (capital C, so normally in fact Shift+c), type -h Enter; you should see the overview of commands, they allow adding and removing port forwardings. Notes:

    • See the manual for details.
    • You need EnableEscapeCommandline yes in your ssh_config (~/.ssh/config) for this ~C to work.
    • The tilde is recognized as the escape character only directly after Enter. Remember this is Enter that gets to the remote side anyway.
  • Set up ServerAliveInterval and ServerAliveCountMax, so you won't be disconnected when idle.

  • If you need more then one terminal, use tmux or screen on the remote side.