Your commands are trying to put the new Document to the root (/
) of your machine. What you want to do is to transfer them to your home directory (since you have no permissions to write to /
). If path to your home is something like /home/erez
try the following:
scp My_file.txt user_id@server:/home/erez/
You can substitute the path to your home directory with the shortcut ~/
, so the following will have the same effect:
scp My_file.txt user_id@server:~/
You can even leave out the path altogether on the remote side; this means your home directory.
scp My_file.txt user_id@server:
That is, to copy the file to your desktop you might want to transfer it to /home/erez/Desktop/
:
scp My_file.txt user_id@server:/home/erez/Desktop/
or using the shortcut:
scp My_file.txt user_id@server:~/Desktop/
or using a relative path on the remote side, which is interpreted relative to your home directory:
scp My_file.txt user_id@server:Desktop/
Edit:
As @ckhan already mentioned, you also have to swap the arguments, it has to be
scp FROM TO
So if you want to copy the file My_file.txt
from the server user_id@server
to your desktop you should try the following:
scp user_id@server:/path/to/My_file.txt ~/Desktop/
If the file My_file.txt
is located in your home directory on the server you may again use the shortcut:
scp user_id@server:~/My_file.txt ~/Desktop/
Best Answer
Consider transferring the whole directory instead of individual files:
If that would transfer too much and you really only want to transfer the files whose names ends with
.json
in the single directory, you may want to considerrsync
(which has better facilities for filtering what gets transferred):This would only copy files whose names end in
.json
but ignore other names. The terminating/
on the source is needed here.The
-a
option makes the transfer also transfer file meta data (timestamps, basically) and makesrsync
recurse down into subdirectories (but this is restricted by--exclude
above), while-v
is for verbose operation.A third option would be to create a
tar
archive of the remote directory, or at least the files that you'd want to transfer, and thenscp
that archive over to the local system. In fact, that could be done in one go withssh
, simulatingscp -r
: