Ok thanks!
It’s not super clear how to open a single connection and then use it with for other connections
Did you try to use the ControlMaster options in the SSH config?
E.g. adding for your computer
controlmaster auto
controlpath /tmp/ssh-%r@%h:%p
in the relevant section of the ~/.ssh/config file.
Then you open one connection in a terminal (with pwd + 2FA), then in a second terminal SSH again and check if this still asks for the PWD.
It might be that it’s blocked by the server. In any case, this might not help with AiiDA because Paramiko does not really support multiplexing… but at least we understand what are the options.
Moreover:
Can you check if what I had described here might work? SSH connection with 2FA (two-factor authentication) using Google Authenticator · Issue #5020 · aiidateam/aiida-core · GitHub
It would be interesting to know if at least in principle their approach to SSH is compatible with the technical solution above.
IMPORTANT NOTE, though: as I stated, you need to check if the center is happy with you doing this - if they are not, you are circumventing their security measures and might ban you (or worse, depending on what they wrote in their regulations)