VS Code Remote SSH not working for server with duo factor authorization

Viewed 836

I'm trying to use VS Code's Remote SSH to work on a server node. However, said server node has duo factor authentication. And whenever I try to connect:

ssh coe62815@birch-gw1.hpccoe.rdlabs.ext.hpe.com

I get these errors as shown from the terminal output:

        This system is for the use of authorized users only. Individuals
        using this computer system are subject to having all of their
        activities on this system monitored and recorded by system
        personnel. All use of this system is subject to the HPE
        Acceptable Use Policy and Confidential Data Policy.

Password:
Duo two-factor login for coe62815

Enter a passcode or select one of the following options:

 1. Duo Push to XXX-XXX-3262

Passcode or option (1-1): 1
63ffe9e60334: running
Acquiring lock on /home/users/coe62815/.vscode-server/bin/83bd43bc519d15e50c4272c6cf5c1479df196a4d/vscode-remote-lock.coe62815.83bd43bc519d15e50c4272c6cf5c1479df196a4d
Found existing installation at /home/users/coe62815/.vscode-server/bin/83bd43bc519d15e50c4272c6cf5c1479df196a4d...
Checking /home/users/coe62815/.vscode-server/.83bd43bc519d15e50c4272c6cf5c1479df196a4d.log and /home/users/coe62815/.vscode-server/.83bd43bc519d15e50c4272c6cf5c1479df196a4d.pid for a running server
Looking for server with pid: 92522
Found running server...

*
* Reminder: You may only use this software with Visual Studio family products, 
* as described in the license (https://go.microsoft.com/fwlink/?linkid=2077057)
*

Checking server status on port 34455 with curl
63ffe9e60334: start 
SSH_AUTH_SOCK====   
DISPLAY====
webUiAccessToken====
listeningOn==34455==
osReleaseId==sles==
arch==x86_64==
tmpDir==/run/user/62815==
platform==linux==
unpackResult====
didLocalDownload==0==
downloadTime====
installTime====
extInstallTime====
serverStartTime====
connectionToken==6335be4c-b6b5-48ac-a43d-4d5f83c48004==
63ffe9e60334: end
channel 3: open failed: connect failed: Connection refused
channel 4: open failed: connect failed: Connection refused

I can connect just fine with Cygwin and just about any other terminal on MacOS/Ubuntu. For some reason this will not let me do it.

Any feedback appreciated

1 Answers

I had the problem that I could not use VS Code's Remote SSH to connect to a 2FA protected server and I fixed it by using SSH ControlMaster for Single Singe-On (piggybacking off the initial connection). I am not sure if this solves your problem but I think it could work.

If you connect to the relevant node using <user_name>@<host_name> you can simply add the following to your ~/.ssh/config:

Host <nickname>
    User <user_name>
    HostName <host_name>
    ControlMaster auto
    ControlPath ~/.ssh/%r@%h:%p

If you now open up a new session in your terminal running ssh <nickname> you will have to go through the normal security steps (normally only entering your password). But all other subsequent ssh sessions (including svn, rsync, etc. that run over ssh) will piggyback off the initial connection without the need for re-authentication.

You can now in VS Code, select Remote-SSH: Connect to Host... from the Command Palette (F1, ⇧⌘P) and simply enter: <nickname> and ControlMaster will automatically connect you using the already standing connection skipping any security steps. enter image description here

In my case, the nickname that I choose is "ody". After connecting VSC's Remote Development extension shows the following in the bottom left corner and lets me browse the files on the remote machine.

enter image description here

From the FASCR:

Note that all subsequent connections are dependent on the initial connection — if you exit or kill the initial connection all other ones die, too. This can obviously be annoying if it happens accidentally. It’s easily avoided by setting up a master connection in the background:

ssh -CX -o ServerAliveInterval=30 -fN <nickname>

The -fN make it go into the background and sit idle, after authenticating. (C for compression,Y for X forwarding, and o ServerAliveInterval=30 to prevent dropped connections have nothing to do with the ControlMaster but are almost always helpful.)

Note that all port forwarding, including X display forwarding, must be setup by the initial connection and cannot be changed.

Related