Search code examples
pythonpycharmremote-debugging

PyCharm: Stuck on Introspecting SSH server because two-factor login required for rsync


I work on a cluster that requires two-factor login for every new connection. When I try creating a remote python interpreter in PyCharm, I can successfully connect, which requires 1 round of two-factor login via Duo. But then, PyCharm tries to test whether rsync works, which requires another round of two-factor authentication:

Successfully connected to rschaef@login.sherlock.stanford.edu:22

> pwd
Failed to execute command


Checking rsync connection...
/usr/bin/rsync -n -e "ssh -p 22 " rschaef@login.sherlock.stanford.edu:

rschaef@login.sherlock.stanford.edu's password: 


(rschaef@login.sherlock.stanford.edu) Duo two-factor login for rschaef



Enter a passcode or select one of the following options:



 1. Duo Push to XXX-XXX-3013

 2. Phone call to XXX-XXX-3013

 3. SMS passcodes to XXX-XXX-3013



Passcode or option (1-3): 

The problem is that PyCharm gives me no way to specify 1, 2 or 3, so I cannot authenticate again for rsync to complete. Consequently, I cannot move past this rsync step. Can someone please help me?


Solution

  • The comment by OP could serve as a good answer already, I elaborate here slightly.

    Multiplexing aggregates all connection into one. To enable multiplexing you should modify ~/.ssh/config on your local machine and add there:

    Host *
        ControlMaster auto
        ControlPath ~/.ssh/control-%r@%h:%p
        ControlPersist 10m
    
    

    You can also limit it to some nodes only by changing Host * into e.g. Host 1.2.3.4.

    Security consideration: make sure that the control path is accessible only by you. It is also possible that remote system admin blocks the multiplexing.