Configure ssh so that password is required only once per work session

This config file allows users to use Teton providing their credentials (password and 2FA) only once per session. Once they are connected, users can open multiple terminals connected with Teton and transfer data between Teton and their machine without providing their password again.

Note: this works under Linux and Mac. I am not sure about Windows (Windows users: edit the page!).

  1. Edit or create ~/.ssh/config

    1 2 3 4 5 6 Host teton Hostname User USERNAME ForwardAgent yes ControlMaster auto ControlPath ~/.ssh/ssh-%r@%h:%p
  2. If you create the config file, it seems to be recommended to modify permissions of this file so that only user can read and modify it chmod 600 ~/.ssh/config

  3. Connect to Teton in your terminal using ssh teton, provide your password and validate with 2FA. KEEP THIS TERMINAL WINDOW OPEN.

  4. Now you can lauch multiple sessions on Teton using ssh teton in new terminal windows, and (a must!) you can transfer files between your machine and Teton without providing password! For synchronizing files/directories between machines, you can use rsync -av teton:PATH_TETON PATH_USER_MACHINE

  5. Once done, exit Teton on all terminals and close the windows. Next time you do ssh teton you will have to provide your password.

    Thanks to @Alex Buerkle who shared this tip that he learned from Jared Baker, formerly of ARCC.