Kasun’s Blog

Kasun Indrasiri

  • Kasun Indrasiri

  • Info

    Department of CSE
    University of Moratuwa,
    Sri Lanka

  • Archives

  • Categories

SCP in 60 seconds

Posted by kasun04 on July 19, 2008

‘Secure Copy’ is a common but a tedious command to remember even for Linux experts. So, I’ll try to present you a clean and complete how to guide on SCP.

scp stands for secure cp (copy), which means that you can copy files across an ssh connection that will be encrypted, and therefore secured. You can this way copy files from or to a remote server, you can even copy files from one remote server to another remote server, without passing through your PC.

Putting a single file

  • devcmb1> scp mydata.dat dev77.fastasa.no:NewData.txt

copy file “mydata.dat” from your current computer/directory to your home directory on dev77.fastasa.no, And re-naming the copy on newton “NewData.txt”.

  • devcmb1> scp mydata.dat dev77.fastasa.no:

Same as the previous one but the file is copied as it is (without renaming).

  • devcmb1> scp mydata.py dev77.fastasa.no:/se/etc/src/ linguistics.py

copy file to a specific directory on dev77.fastasa.no, giving the file a new name there.

  • ktest@tframe. fastasa.no>

scp mydata.dat kasundev@dev77.fastasa.no:new.dat

copy file from your account on tframe to your home directory on dev77, where your username is different (kasundev)

Getting a single file

  • devcmb1> scp dev77.fastasa.no:mydata.dat ./mydata.dat

copies file “mydata.dat” from the your home directory on dev77 to your current working directory on devcmb1

  • devcmb> scp dev77.fastasa.no:mydata.dat ./

same thing — it is enough just to indicate the directory, and the copied file will be named the same as the original, by default

  • devcmb> scp kasundev@dev77.fastasa.no:cvs/se/test.xml ./

gets the file from my “cvs/se” subdirectory (relative to kasundev’s home directory on dev77)

Putting an entire directory

  • devcmb> scp -r my_source dev77.fastasa.no:Mysrc/bck/

copy directory “ my_source ” recursively (i.e., the directory and all its contents) from devcmb into a new directory “bck” in your home directory on dev77 (the directory “Mysrc” must already exist).

(Anyway I prefer to create a tar file and copy that files to the destination and unpack it … This is more clean.. I guess.. 🙂)

Getting an entire directory

  • devcmb> scp -r kasun@dev70:MySrc/bck ./my_src/

copy directory “Mysrc/bck/” recursively (i.e., the directory and all its contents) from dev70 (where you are “kasun” into a new directory “my_src” in your current working directory on devcmb.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: