Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SCP gives "File or directory not found"

I am having an issue. I am using the SCP command to transfer files from my desktop of my mac osx too my virtual server. The thing is I ran the command and successfully transferred one file from my desktop over to the server, no problem.

So i use the same command which is: scp filename_I_want_to_transfer user@serverip:

So basically that looks like scp test [email protected]: (I just used random IP for example)

Anyways on the second file I'm trying to transfer which is also in the document format I continually get "No such file or directory". Any ideas on why this might be happening?

like image 805
Johnathon22 Avatar asked Nov 26 '14 16:11

Johnathon22


People also ask

Does scp work for directory?

To copy a directory (and all the files it contains), use scp with the -r option. This tells scp to recursively copy the source directory and its contents.

Where does scp put files?

Copy Files and Directories Between Two Systems with scp The /remote/directory is the path to the directory you want to copy the file to. If you don't specify a remote directory, the file will be copied to the remote user home directory.


3 Answers

To send a file from the local host to another server use:

scp /path/to/file.doc user@<IP or hostname>:/path/to/where/it/should/go/

To get a file from another server to the local host use:

scp user@<IP or hostname>:/path/to/file.doc /path/to/where/it/should/go/

This is the format I reliably use for copying from a location to another location. You can use absolute path, or relative/special character path, such as

scp suiterdev@fakeserver:~/folder/file .

which would be "Securely copy the file named file in $HOME/folder/ (~ equivalent to ~suiterdev or $HOME) as user suiterdev from host fakeserver to the current directory (.).

However you'll have to take care that special characters (see the shell's filename expansion mechanism) used for the remote path are not expanded locally (because that typically is not what you want).

like image 171
suiterdev Avatar answered Oct 01 '22 22:10

suiterdev


Well for me am using Ubuntu 15.10 and this is what worked for me.

scp [email protected]:path/to/file.txt /home/to/local/folder/

instead of

scp [email protected]:/path/to/file.txt /home/to/local/folder/

Note that after [email protected] host i do not include the forward slash i immediately append the folder after the ":"

Scp uses the target user's home directory as default directory (as a relative path), so when you need an absolute path, then use one (starting with a slash (/)).

like image 42
kalibbala Avatar answered Oct 01 '22 22:10

kalibbala


I know this is way too late for this to help you, but it may help others who had the same problem as me for my case my pc is set up to use backwards slash "\" instead of forward slash "/" and changing to backwards slashes removed the errors

But I only had to change the slashes to backward slashes on my pc's directory as my raspberry pi uses forward slashes.
I know it is a bit confusing but it worked for me.

like image 33
Htennek Avatar answered Oct 02 '22 00:10

Htennek