I would like to transfer a zip file from my local server to a remote server. I used the following command which contain host, port, and username as follows:

scp "$somepath/${file}.zip" "$ftp_user"@"ftp_server":upload/

In this command:


This command is failing to connect. Would you please advise me?

  • 3
    What was the error message? – Jeff Schaller Sep 4 '18 at 15:07
  • no error message it take its time and loss the connection. – Nirmolendu Singha Sep 4 '18 at 15:09
  • What exactly does it report back to you? – roaima Sep 4 '18 at 16:06
  • Connection time out lost connection and error : FTP transfer fail – Nirmolendu Singha Sep 4 '18 at 16:26
  • The error messages you reported ("time out", "connection lost", and "FTP transfer fail" indicate that your scp command is either not connecting to the remote host at all (networking issue) or the remote host is not serving the ssh/scp protocol. Given the confusion between scp and FTP, what method to you expect to be able to use to transfer the file, and are you certain that the remote server has that service running? Can you ping that remote server? – Jeff Schaller Sep 4 '18 at 16:37

scp uses the SSH protocol to transfer files, so it needs an SSH account.

Looks like you need to connect to the server via FTP, so you should use one of the many ftp clients.

I've always liked lftp best.

  • will try to connect using lftp. – Nirmolendu Singha Sep 4 '18 at 15:10
  • i have changed from scp to lftp in the above code and it is showing command not found FTP fails -<> – Nirmolendu Singha Sep 4 '18 at 15:18
  • @NirmolenduSingha you have to install lftp first, and the syntax is different. thale a look at the link I posted in the answer for usage instructions. – Mr Shunz Sep 4 '18 at 15:19
  • Do we have any command without installing anything – Nirmolendu Singha Sep 4 '18 at 15:53
  • @NirmolenduSingha you can try ftp which is very limited but should be present in nearly every system. – Mr Shunz Sep 4 '18 at 15:56

You forgot to add $ before variables name, so they are not expanding to the correct values you set.


scp "$somepath/${file}.zip" "$ftp_user"@"$ftp_server":upload/
  • and the target folder should under / like, /upload or /some/dir/upload – msp9011 Sep 4 '18 at 16:09
  • I tried with Target :/upload but not working – Nirmolendu Singha Sep 4 '18 at 16:28

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.