On Linux, the OpenSSH connection-sharing options ControlMaster and ControlPersist allow an authenticated SSH connection to be reused for a specified period.
Add the following settings to ~/.ssh/config.
|
1 2 3 4 |
Host squidhpc.hpc.cmc.osaka-u.ac.jp squidhpda.hpc.cmc.osaka-u.ac.jp octopus.hpc.osaka-u.ac.jp ControlMaster auto ControlPath ~/.ssh/control-%C ControlPersist 60m |
Two-factor authentication is required as usual for the first connection.
After the last SSH session is closed, the authenticated connection remains active for up to 60 minutes and can be reused for subsequent connections during that period.
Notes
- ・This FAQ applies to Linux environments. On Windows, please use a Linux environment such as WSL.
- ・We recommend setting the
ControlPersistduration to no more than 60 minutes. - ・On shared computers, the authenticated SSH connection remains active in the background. Therefore, the use of
ControlPersistis not recommended. - ・Two-factor authentication is required again after the retention period expires or the retained connection is terminated.
Supplement: Terminating a Persistent SSH Connection
If you want to terminate an SSH connection maintained by ControlPersist before the persistence period expires,
simply closing the terminal window may leave the authenticated SSH connection running in the background.
To explicitly terminate the persistent connection, shut down the Linux environment you are using or run the following command:
|
1 |
ssh -O exit username@hostname |
This command terminates the persistent SSH connection to the specified host.
Two-factor authentication will be required again the next time you connect via SSH.

