Ubuntu: Using “put” command in sftp gives “no such file or directory”


I've reviewed this topic: How to fix No Such File Or Directory Error message while using sftp Command and some others, however nothing helped me solve this.

Simply put I'm trying to move a file named blankfile.txt which is located on my desktop directory on a local machine onto my remote directory in the LAMP server.

I've tried:

put Desktop/blankfile.txt    put blankfile.txt 192.168.x.x:/home/user/Desktop/  put /home/user/Desktop/blankfile.txt  

(while typing it from the remote working directory)

What am I doing wrong?


My guess is that you're not in the correct local path, to find out where is your current directory at your local machine, use: lpwd.

If you where in a wrong path then use lcd to move into correct path for example:

lcd ~/Desktop  

Know to make sure all your files are in place use: lls to get a list of your local files. or even something like this:

lls blankfile.txt  

To make sure it's there. then you can use put to start uploading it to remote machine:

put blankfile.txt  

If you've been encountered to any permission error, use pwd command to find out where you are at your remote machine.

If you are in a path like /var and you did sftp with a normal user, it's obvious that you can't upload your files there, in this case you will get an error like:

remote open("/root/blankfile.txt"): Permission denied  

Use cd command to change into a directory that you are permitted to write and then use put command.

The other permission issue that could happen is your local file permission, which will produce:

Couldn't open local file "blankfile.txt" for reading: Permission denied  

Check your local file permission with lls -l blankfile.txt, make sure your current user at your local machine has a right to read that file.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »