Page 2 of 6 FirstFirst 1234 ... LastLast
Results 11 to 20 of 57

Thread: How can I connect to SFTP using Nautilus (Files)

  1. #11
    Join Date
    Oct 2005
    Location
    Lab, Slovakia
    Beans
    10,435

    Re: How can I connect to SFTP using Nautilus (Files)

    Check whether the underlying network services work using nslookup, telnet, dig or ssh:
    $ nslookup [domain]
    $ dig [domain]
    $ telnet [domain]
    $ sftp -vvv [user@domain]

    The error messages will tell you what is amiss.

    If it doesn't work try connecting with the IP address:
    $ telnet ip.add.re.ss

    If you get a prompt from the server, then the network is OK. If you don't get a prompt then fix the system before carrying on, else you are just poking a dead horse.
    Last edited by HermanAB; July 30th, 2021 at 01:17 PM.

  2. #12
    Join Date
    May 2006
    Location
    Switzerland
    Beans
    2,904
    Distro
    Ubuntu 20.04 Focal Fossa

    Re: How can I connect to SFTP using Nautilus (Files)

    Quote Originally Posted by Paddy Landau View Post
    I tried:
    sftp [user]@[domain]:[port]/
    What about the syntax I used above?
    Code:
    sftp -P port remoteuser@server:/path/to/location
    Quote Originally Posted by Paddy Landau View Post
    Reading the sftp manual, it says that details are passed to ssh. This confuses me...
    SFTP client will read ~/.ssh/* too. So does Nautilus.

    Quote Originally Posted by Paddy Landau View Post
    ... because I have only SFTP access and not SSH access
    Yes, you won't get an interactive shell if you access that remote system. There are various ways to achieve that. But for Nautilus ssh:// and sftp:// are the same thing, for practical purposes (since it's not trying to achieve an interactive shell, just transfer files...). And Nautilus does respect settings in ~/.ssh/* too, so if key authentication is properly configured and it works on the command line, then it should also work in Nautilus.

    Quote Originally Posted by Paddy Landau View Post
    ... because from what I understand SFTP means FTP over SSH ...
    Only for historical reasons. SFTP apart from sharing the same three letters and apart from using the same or similar commands in its command line client (so people don't have to relearn everything) has nothing to do with the ancient FTP dinosaur from the 1970's. SFTP is an integral sub-protocol of SSH. Your description of "FTP over SSH" is thus not accurate.

    Since "sftp" and Nautilus should respect settings in ~/.ssh/* ... let's do this: Let's write a custom ~/.ssh/config file for that specific remote server. The content should be something like this:

    Code:
    Host nickname-for-your-sftp-connection   # this is just an alias so you don't have to type the whole damn IP address or DNS name every time
      Hostname real-server.fqdn.internet.address-or-ip
      Port 9999   # replace with actual custom port number
      User yourusername   #  which username should be tried by default?
    Actual example from one of my own systems:

    Code:
    Host jump
      Hostname ssh-jump-host.cloudprovider.super-long-annoying-letters-and-numbers-string-right-here.servernetwork.country.tld
      Port 32578
      User clouduseraccount
    So ... on my system when I type in e.g.
    Code:
    ssh jump
    sftp jump
    ... or when I open Nautilus with:
    Code:
    sftp://jump
    ssh://jump
    ... then either will correctly perform an auto-login on the right machine and the right custom SSH port, using the right username and the right SSH keys. I don't ever get to see a password prompt. It just works.

    Try this?

  3. #13
    Join Date
    May 2006
    Location
    Switzerland
    Beans
    2,904
    Distro
    Ubuntu 20.04 Focal Fossa

    Re: How can I connect to SFTP using Nautilus (Files)

    Quote Originally Posted by HermanAB View Post
    If it doesn't work try connecting with the IP address:
    $ telnet ip.add.re.ss

    If you get a prompt from the server, then the network is OK.
    Bold of you to assume that anyone still uses telnet these days and that you'd actually get any reaction whatsoever from anyone on port 23 ...

  4. #14
    Join Date
    May 2008
    Location
    United Kingdom
    Beans
    4,784
    Distro
    Lubuntu 18.04 Bionic Beaver

    Re: How can I connect to SFTP using Nautilus (Files)

    Well, those replies have been interesting and informative, thank you!

    I have made some progress.

    I've made an entry in my ~/.ssh/config file for this. I named the entry sg. Using sg, I get the following results.

    Code:
    sftp -vvv sg
    This goes as far as asking for my password, but doesn't manage to connect. The final messages after entering my private key's password read:
    Code:
    debug3: sign_and_send_pubkey: RSA SHA256:[redacted]debug3: sign_and_send_pubkey: signing using ssh-rsa SHA256:[redacted]
    debug3: send packet: type 50
    debug2: we sent a publickey packet, wait for reply
    debug3: receive packet: type 51
    debug1: Authentications that can continue: publickey
    debug2: we did not send a packet, disable method
    debug1: No more authentication methods to try.
    [user]@[host]: Permission denied (publickey).
    Connection closed.  
    Connection closed
    Connecting from Nautilus does similar, although I can't see error messages. In the connection field, I enter:
    Code:
    sftp://sg
    Nautilus prompts me for the private key's password, and again gives me the message, "Unable to access location. Permission denied."

    Progress… but still not success!
    Always make regular backups of your data (and test them).
    Visit Full Circle Magazine for beginners and seasoned Linux enthusiasts.

  5. #15
    Join Date
    May 2006
    Location
    Switzerland
    Beans
    2,904
    Distro
    Ubuntu 20.04 Focal Fossa

    Re: How can I connect to SFTP using Nautilus (Files)

    Looks to me like there's an issue with your SSH key based authentication. If the command line does fail then so will Nautilus.

    But you said FileZilla works? Can you show us via screenshots (... maybe edit them and blur out or black out sensitive information!! ...) how you configured it there? We need to replicate that configuration for the command line. Then Nautilus will work too.

  6. #16
    Join Date
    May 2008
    Location
    United Kingdom
    Beans
    4,784
    Distro
    Lubuntu 18.04 Bionic Beaver

    Re: How can I connect to SFTP using Nautilus (Files)

    Quote Originally Posted by scorp123 View Post
    Looks to me like there's an issue with your SSH key based authentication. If the command line does fail then so will Nautilus.

    But you said FileZilla works? Can you show us via screenshots (... maybe edit them and blur out or black out sensitive information!! ...) how you configured it there? We need to replicate that configuration for the command line. Then Nautilus will work too.
    Ah… good point!

    I forgot that when I gave FileZilla the key, it converted it into a different format (with the same password).

    But, when I use that converted key file with either sftp (command line) or Nautilus, they both fail straight away. So, that's a regression; unless I have to pass some sort of parameter to sftp or Nautilus?

    To answer your question, I've attached a screenshot of FileZilla's connection details. When I ask to connect, FileZilla simply asks me for the password. (I use a password manager to hold my password, so I know that I'm using the same password each time.)

    I might have to come back to this tomorrow, as I'm running out of time for today.
    Attached Images Attached Images
    Always make regular backups of your data (and test them).
    Visit Full Circle Magazine for beginners and seasoned Linux enthusiasts.

  7. #17
    Join Date
    May 2006
    Location
    Switzerland
    Beans
    2,904
    Distro
    Ubuntu 20.04 Focal Fossa

    Re: How can I connect to SFTP using Nautilus (Files)

    Quote Originally Posted by Paddy Landau View Post
    I forgot that when I gave FileZilla the key, it converted it into a different format (with the same password).
    Yes, FileZilla uses Putty's *.PPK format ...
    https://docs.oracle.com/en/cloud/paa...te-key-format/

    On Linux there's a command line tool with the name "puttygen" to convert SSH keys from one format into the other:
    http://manpages.ubuntu.com/manpages/...uttygen.1.html

    A GUI program with that same name (PuttyGen.EXE) also exists on Windows.


    Quote Originally Posted by Paddy Landau View Post
    But, when I use that converted key file with either sftp (command line) or Nautilus, they both fail straight away.
    Of course. They expect keys to be in OpenSSH's format. And they expect that key to be in ~./ssh/id_rsa (that's me guessing from the screenshot and what I can see on it ...)

    Quote Originally Posted by Paddy Landau View Post
    So, that's a regression; unless I have to pass some sort of parameter to sftp or Nautilus?
    Not a regression, but it seems you were trying to use a SSH key in Putty's *.PPK format on two applications that expect SSH keys to be in the traditional OpenSSH format. That will not work.

    Quote Originally Posted by Paddy Landau View Post
    To answer your question, I've attached a screenshot of FileZilla's connection details. When I ask to connect, FileZilla simply asks me for the password.
    Is that really a password ... or rather a passphrase? If that's a passphrase we may have to work with "ssh-agent" too so the key auto-unlocks upon your login into the system.

    Background info:
    https://en.wikipedia.org/wiki/Ssh-agent

  8. #18
    Join Date
    May 2008
    Location
    United Kingdom
    Beans
    4,784
    Distro
    Lubuntu 18.04 Bionic Beaver

    Re: How can I connect to SFTP using Nautilus (Files)

    Thanks for your replies, @scorp123.
    Quote Originally Posted by scorp123 View Post
    Is that really a password ... or rather a passphrase? If that's a passphrase we may have to work with "ssh-agent" too so the key auto-unlocks upon your login into the system.
    Passphrase, password — aren't they the same thing in this context?

    Can Nautilus work with ssh-agent? I hadn't heard of ssh-agent.
    Always make regular backups of your data (and test them).
    Visit Full Circle Magazine for beginners and seasoned Linux enthusiasts.

  9. #19
    Join Date
    May 2006
    Location
    Switzerland
    Beans
    2,904
    Distro
    Ubuntu 20.04 Focal Fossa

    Re: How can I connect to SFTP using Nautilus (Files)

    Quote Originally Posted by Paddy Landau View Post
    Passphrase, password — aren't they the same thing in this context?
    Not exactly. If password-based login is configured then you can get in no matter what the key says. You knew the correct username and the correct password and therefore you may pass and get in. With a passphrase it gets more complicated: Without knowing or providing the correct passphrase a SSH key will not be read. So even if you do know the correct remote username and do have the right SSH key ... without passphrase the key remains locked and the login will fail no matter what.

    Quote Originally Posted by Paddy Landau View Post
    Can Nautilus work with ssh-agent? I hadn't heard of ssh-agent.
    Correctly setup the SSH agent is totally transparent to the system and "it just works" for the whole OS. So... no, Nautilus doesn't know how to handle SSH agent. But then again it does not need to. I haven't used GNOME in a while but if I remember correctly then GNOME's keyring should be able to handle it too ... Googling gives me links like this one:
    https://wiki.gnome.org/Projects/GnomeKeyring/Ssh

    So I guess getting it configured in GNOME's keyring would make it work for Nautilus too...

    Another more traditional way of getting SSH agent to work is to e.g. add these lines to your ~/.bashrc :

    Code:
    AGENT_PID=$(ps -ef | grep ssh-agent | awk '{ print $2 }')
    if [ -z "$AGENT_PID" ]; then
      echo "Starting SSH Agent!"
      eval `ssh-agent` && ssh-add ~/.ssh/id_rsa
      setx SSH_AUTH_SOCK $SSH_AUTH_SOCK
      setx SSH_AGENT_PID $SSH_AGENT_PID
      echo "SSH Agent running (PID: $SSH_AGENT_PID)"
    else
      echo "SSH Agent already running (PID: $AGENT_PID)"
    fi
    echo
    So this of course would only activate if you open a new Terminal ... but if you planned on using a command line tool anyway then this might be sufficient too? It would also work for the rest of the OS, the big downside just being that you'd need to manually open a Terminal before this stuff activates.

    Since you intend to work with Nautilus this is a "Plan B" at best. "Plan A" should be to get it working with GNOME keyring.

  10. #20
    Join Date
    May 2008
    Location
    United Kingdom
    Beans
    4,784
    Distro
    Lubuntu 18.04 Bionic Beaver

    Re: How can I connect to SFTP using Nautilus (Files)

    Quote Originally Posted by scorp123 View Post
    Not exactly. If password-based login is configured…
    I think that I understand what you're getting at. This is the passphrase for the private key itself, rather than a password to access SSH. I can't get in without the private key. I could generate a private key without a passphrase, in which case I wouldn't have to bother about it at all.

    Quote Originally Posted by scorp123 View Post
    So I guess getting it configured in GNOME's keyring would make it work for Nautilus too...
    I added the key using ssh-add as you described. It seems to be there, because if I exit the terminal and re-enter it, "ssh-add -l" and "ssh-add -L" both list the key.

    Unfortunately, this hasn't helped Nautilus.

    I opened the app Password and Keys (seahorse), and I could see the key there having been saved by Nautilus. But, I don't know how to add it there otherwise.

    This seems to be unreasonably difficult for something so well established!
    Always make regular backups of your data (and test them).
    Visit Full Circle Magazine for beginners and seasoned Linux enthusiasts.

Page 2 of 6 FirstFirst 1234 ... LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •