4

So I used SSH to remotely login to another computer on a network. I have many files that I would like to copy over to my local desktop.

A screenshot of the files I want

I am trying to follow this How-to :

However, I think one of the problems is that I may not know what goes in place of /home/name/dir

I tried using scp

scp rrtigga@pc35.cs.ucdavis.edu:CPUTimer.h /Users/Spicycurryman/Desktop

But then I got this error:

/Users/Spicycurryman/Desktop: No such file or directory
  • Use Desktop/... – jasonwryan Jun 26 '14 at 22:42
  • I did and I don't see it – XiJiaoping Jun 26 '14 at 22:46
  • I think the Desktop above isn't the local one so I'm not sure what to do – XiJiaoping Jun 26 '14 at 22:54
  • 2
    I don't believe there is a rule against posting an image of terminal output / code, but if there isn't. There should be. In the future, please consider pasting the output in a code block. – HalosGhost Jun 26 '14 at 22:58
  • Where did you enter the scp command? On your local computer (MacBook Air, as it seems) or on the remote computer? The command as you typed it must be entered on your local computer, not the remote one you are copying from. – Dubu Jun 27 '14 at 6:41
2

You don't have to give an absolute path to scp — the easiest way to deal with this is to go where you want to put things and use scp rrtigga@pc35.cs.ucdavis.edu:CPUTimer.h . (. refers to the current directory), or give a relative path like Desktop. You can also use ~/Desktop to refer to the Desktop directory within your home directory from anywhere.

If you have lots of files to copy from one place, you may find rsync more convenient:

rsync -avx rrtigga@pc35.cs.ucdavis.edu:foo .

That will copy the entire "foo" directory and its contents to the current directory.

3

If you know the name of the file(s) you want to copy, there is no need to ssh to the remote server before using scp to copy the file(s). This should do the trick:

scp rrtigga@pc35.cs.ucdavis.edu:~/CPUTimer.h .

This will copy the file CPUTimer.h from the home directory of rrtigga on pc35.cs.ucdavis.edu to the present working directory on the local machine.

If you would rather do the scp after using ssh to connect to pc35.cs.ucdavis.edu use scp like this:

scp ~/CPUTimer.h your_local_machine_IP_address:~/.

Substitute you local machine IP here ^^^

This will copy CPUTimer.h to the home directory of the user executing scp on the local machine.

2

sftp is a useful alternative for transferring files and archives over SSH.

Start a connection while in your target directory and use FTP commmads to transfer files.

$ sftp user@host
Connected to host
sftp> cd /usr/local/src
sftp> pwd
Remote working directory: /usr/local/src
sftp> put file.tgz
sftp> get file.tgz
  • sftp is life saver... – tyan Oct 19 '17 at 12:59
1

You can try this scp -r username@xx.xx.xx.xxx:/remote/dir/path/ /local/dir/path/. For example,If I want to copy a file called sample.txt residing in home directory of remote system z having IP ab.ab.ab.cde to my local system l path ~/Desktop/ then the command will be scp z@ab.ab.ab.cde:~/sample.txt ~/Desktop/. You can suffix -r to scp to copy the directories from remote system.

0

The reason why you are getting this is because you have not put in the ditectory the file is in. Try:

scp rrtigga@pc35.cs.ucdavis.edu:~/CPUTimer.h /Users/Spicycurryman/Desktop

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.