Page 1 of 2 12 LastLast
Results 1 to 10 of 14
  1. #1
    Join Date
    Oct 2011
    Location
    Dublin, PA
    Posts
    381
    Thanks
    33
    Thanked 18 Times in 16 Posts
    Rep Power
    10

    Upload files with ssh / scp in Linux

    Throughout the day, you'll probably find yourself needing to upload files to various sites/servers. A great secure way to quickly move files around from server to server is to use the scp command. Let's say you need to copy a picture of a donut into your document root on server3.

    Code:
    scp /home/rob/pictures/donuts/half-eaten.jpg rob@server3:/home/mywebsite.com/public_html/images/
    Now, the picture "half-eaten.jpg" is on the mywebsite.com website in the images directory.. Let's work through the command:

    scp = our Linux command
    /home/rob/pictures/donuts/ = the directory where half-eaten.jpg resides
    half-eaten.jpg = our file
    rob@server3 = our username on server3
    /home/mywebsite.com/public_html/images/ = the directory on server3 where we'd like to put the image

    Let's try another one - say you need to grab the logo from that site so you can add a picture of a donut to it in gimp..
    Code:
    scp rob@server3:/home/mywebsite.com/public_html/images/mylogo.png /home/pictures/
    This will grab the logo and put it in your /home/pictures/ directory.

    This is a lot more fun if you have SSH keys set up, we also recommend using screen if you're going to be uploading things that may take a while.




  2. #2
    Join Date
    Nov 2011
    Posts
    88
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    2
    I don't understand how this works...are you copying files from your local pc or from another server or what?

  3. #3
    Join Date
    Nov 2011
    Location
    GMT +8
    Posts
    212
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Rep Power
    2
    Quote Originally Posted by MustangV10 View Post
    I don't understand how this works...are you copying files from your local pc or from another server or what?
    I think it works for anything so long as you know what's the source server and the destination server. Just curious. What does scp stand for? I would think the'cp' means 'copy', right?

  4. #4
    Join Date
    Oct 2011
    Location
    Dublin, PA
    Posts
    381
    Thanks
    33
    Thanked 18 Times in 16 Posts
    Rep Power
    10
    Quote Originally Posted by MustangV10 View Post
    I don't understand how this works...are you copying files from your local pc or from another server or what?
    Yes, from your local linux pc (or where ever your terminal is based.. 'server a')

    Picture it like command line ftp.

  5. #5
    Join Date
    Oct 2011
    Location
    Dublin, PA
    Posts
    381
    Thanks
    33
    Thanked 18 Times in 16 Posts
    Rep Power
    10
    Quote Originally Posted by Victor Leigh View Post
    I think it works for anything so long as you know what's the source server and the destination server. Just curious. What does scp stand for? I would think the'cp' means 'copy', right?
    Yup.. you're right

    scp stands for 'secure cp' or 'secure copy'

  6. #6
    Join Date
    Nov 2011
    Location
    GMT +8
    Posts
    212
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Rep Power
    2
    Quote Originally Posted by Rob View Post
    Yup.. you're right

    scp stands for 'secure cp' or 'secure copy'
    Thank you. Just curious. How does it become secure? Does it use an SSL connection like when we log into a https address?

  7. #7
    Join Date
    Nov 2011
    Posts
    71
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Rep Power
    2
    This is using ssh to copy the files vs. using FTP or a non-encrypted protocol.

  8. #8
    Join Date
    Jan 2012
    Posts
    124
    Thanks
    0
    Thanked 10 Times in 10 Posts
    Rep Power
    2
    This is a lot more fun if you have SSH keys set up, we also recommend using screen if you're going to be uploading things that may take a while.
    Adding SSH keys to the mix also makes it far more secure due to the fact your password won't be transmitted via plain-text. But, screen is useful I find only if you do not have a tab-capable terminal (i.e.: using putty or a GUI-less box). Its still a very powerful and useful tool, but I think people often overlook the capabilities of terminal emulators (like Konsole) these days.
    Information Server Management
    Linux server management, PCI consultation and affordable web hosting.

    Security For Us - Where security works for you

    Providing server security and PCI compliance for individuals and businesses.

  9. #9
    Join Date
    Feb 2012
    Posts
    15
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Even the questions are helping me to better understand applications. You have some very smart people on this forum. Thank you to all of you assisting me.

  10. #10
    Join Date
    Feb 2012
    Posts
    90
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Rep Power
    2
    The option -r is also worth mentoning. It copies a dir recursively.

 

 

Similar Threads

  1. Replies: 1
    Last Post: 11-19-2011, 07:36 PM
  2. Back Up Files With Déjà Dup (Linux Mint 11)
    By Fred in forum Linux News
    Replies: 0
    Last Post: 11-16-2011, 10:40 PM
  3. Replies: 1
    Last Post: 11-06-2011, 01:18 AM
  4. Remove files older than X
    By Rob in forum Command Line
    Replies: 1
    Last Post: 11-03-2011, 08:06 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
           








Check out Linux Central for Linux software and other goodies!





» Stats

Members: 3,546
Threads: 3,914
Posts: 9,425
Top Poster: Fred (1,486)
Welcome to our newest member, Arnaud

» Links



Powered by vBadvanced CMPS