If I try and access my FTP server via the command line using (sudo) sftp 192.168.1.x/home/directory the terminal returns

sftp: 192.168.1.x/home/directory: Name or service not known

But if I enter sftp://192.168.1.x/home/directory into Nautilus the directory is accessible.

Why am I not able to access the ftp server with the command line?

I have been having problems with FTP and backing up my system since yesterday so I might be missing something obvious by now. Sorry if that is the case.

  • Are you sure that you completely understand the terminology? SFTP is SSH-ed FTP. FTP is insecure, FTPS is FTP with SSL security. What server do you use? OpenSSH or VsftpD? – N0rbert Oct 14 '18 at 13:29
  • I use openSSH to connect to my server via ssh and also use vsftp. My problems started when I upgraded my server to from 16.04 to 18.04 and my Deja Dup GUI could no longer backup my laptop. I had to alter the storage target to sftp://192.168.1.x/home/directory to get it to work. Previously it was ftp://directory@192.168.1.x/ for many years. I am trying to figure out what has happened for this long-term solution to stop working. – SteveInBavaria Oct 14 '18 at 13:57
  • 1
    Sounds interesting. I use sshfs to mount SFTP to the mount-point (see example in this answer). It is fast and reliable. Or Nautilus/Caja to mount sftp for copying/moving one or two files. I have never used Deja Dup. I use FreeFileSync for periodical but manual backups. – N0rbert Oct 14 '18 at 14:10
  • 1
    I have used Deja Dup for years now and am very happy with it. I found the command sftp://192.168.1.x/home/directory by connecting via Nautilus and so everything is working again now. But I am interested in what exactly has changed and it is so long ago that I set up the OpenSSH, vsftp anf other servers on my server machine that I have forgotten 90% of how I did it ;-) – SteveInBavaria Oct 14 '18 at 14:23

According to man sftp:

 sftp [user@]host[:file ...]

So you need a colon : between the server name and path.

sftp 192.168.1.x:/home/directory

Or better still, use a tilde ~ for the home directory!

sftp 192.168.1.x:~/
  • Thanks but even adding a colon didn't change the result. Still the same warning. – SteveInBavaria Oct 14 '18 at 13:48

I finally discovered why the SFTP wasn't working in the command line, it was because somehow during the upgrade from 16.04 to 18.04 the bash shell had been removed from the user "directory". I found this out by looking at /etc/passwd and noticed that the entry for "directory" had /usr/bin/nologin next to it. I entered the following command to fiy the problem.

sudo usermod --shell /bin/bash directory

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.