1

I can ssh to a server that has 2FA, but I can't access it through Ubuntu (20.04) nautilus sftp. sftp://hostname.com or sftp://[email protected] results in time out, adding port 22 does not help. All I want is to browse through the server directories graphically in nautilus. Note that ssh keys are not accepted in my remote server where I don't have root access and I simply cannot suggest any changes to the admin. Please help.

I am surprised to see that an android app can do the above (termius). I just provided my username (and password) and hostname and it works there (it just asks for the otp). Can we do the same in nautilus?

1 Answer 1

0
+50

Although Nautilus implements its own SFTP client code, it still uses the OpenSSH ssh tool under the hood, which is not very programmable when it comes to authentication – i.e. Nautilus cannot easily distinguish local prompts shown by the client from remote output from the server, so it has to look for the literal text password: and assume that's the password prompt.

(The Android app, meanwhile, uses an SSH client library that is specifically meant to be driven via code, so it knows exactly what prompts are being received and when the actual "session" starts.)

You can work around this by manually starting the connection using OpenSSH's multiplexing mode, which allows further ssh invocations to re-use an existing connection. The -M and -S options, as well as ControlMaster and ControlPath, apply here.

For current GVFS versions (1.47 and later), which already use multiplexing internally, you need to specify a particular location for the multiplex socket that GVFS will be looking at:

$ ssh -fNMS "$XDG_RUNTIME_DIR/gvfsd-sftp/%C" user@remotehost
Enter PIN for 'etoken_foo':

$ gio mount sftp://user@remotehost

If the OTP prompt does not show up, omit the -f and -N options to start an interactive shell connection instead, then just leave that shell open in background.

For older GVFS versions (1.46 and older), and/or for interactive ssh invocations, you need to define a default socket location in your ~/.ssh/config file (i.e. the global equivalent of -S):

Host *
    ControlPath ~/.ssh/S.%r@%h:%p

Then start a background connection using ssh -fNM user@thathost and the subsequent GVFS mount will automatically use it (and so will another ssh user@thathost).

2
  • Can't believe what an andriod app can do no linux file manager can't do out of the box, shame!
    – user43280
    May 11, 2023 at 15:57
  • ¯\_(ツ)_/¯ I've been waiting for any Android app to do Kerberos, something which Nautilus can do out of the box, and yet. May 11, 2023 at 16:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .