How to copy a file from a remote network to the local desktop

108,110

Solution 1

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 [email protected]: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 [email protected]:foo .

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

Solution 2

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 [email protected]:~/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.

Solution 3

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

Solution 4

You can try this scp -r [email protected]:/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 [email protected]:~/sample.txt ~/Desktop/. You can suffix -r to scp to copy the directories from remote system.

Share:
108,110

Related videos on Youtube

XiJiaoping
Author by

XiJiaoping

Updated on September 18, 2022

Comments

  • XiJiaoping
    XiJiaoping over 1 year

    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 [email protected]:CPUTimer.h /Users/Spicycurryman/Desktop
    

    But then I got this error:

    /Users/Spicycurryman/Desktop: No such file or directory
    
    • jasonwryan
      jasonwryan almost 10 years
      Use Desktop/...
    • XiJiaoping
      XiJiaoping almost 10 years
      I did and I don't see it
    • XiJiaoping
      XiJiaoping almost 10 years
      I think the Desktop above isn't the local one so I'm not sure what to do
    • Jakob Bennemann
      Jakob Bennemann almost 10 years
      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.
    • mleonard
      mleonard almost 10 years
      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.
  • tyan
    tyan over 6 years
    sftp is life saver...
  • skm
    skm about 4 years
    @creek where the file 'file.tgz' sits initially? when using "put file.tgz" where it goes when using "get file.tgz" Regards
  • Chad K
    Chad K about 4 years
    file.tgz would exist in the directory you were in when the sftp session was started. If you want to upload /data/file.tgz then cd /data; sftp user@host