Purchase Linux CDs / DVDs / Flash Drives at OSDisc.com

Welcome to Our Community

While Linux.org has been around for a while, we recently changed management and had to purge most of the content (including users). If you signed up before April 23rd please sign up again. Thanks!

Upload files with ssh / scp in Linux

Discussion in 'Shell / Command Line' started by Rob, Nov 21, 2011.

  1. Rob

    Rob Guest

    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.

    scp /home/rob/pictures/donuts/half-eaten.jpg [email protected]:/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
    [email protected] = 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..
    scp [email protected]:/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. MustangV10

    MustangV10 Guest

    I don't understand how this works...are you copying files from your local pc or from another server or what?
  3. Victor Leigh

    Victor Leigh Guest

    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. Rob

    Rob Guest

    Yes, from your local linux pc (or where ever your terminal is based.. 'server a')

    Picture it like command line ftp.
  5. Rob

    Rob Guest

    Yup.. you're right :)

    scp stands for 'secure cp' or 'secure copy'
  6. Victor Leigh

    Victor Leigh Guest

    Thank you. Just curious. How does it become secure? Does it use an SSL connection like when we log into a https address?
  7. grim76

    grim76 Guest

    This is using ssh to copy the files vs. using FTP or a non-encrypted protocol.
  8. ehansen

    ehansen Guest

    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.
  9. goodselfme

    goodselfme Guest

    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. carbon333

    carbon333 Guest

    The option -r is also worth mentoning. It copies a dir recursively.
  11. Akendo

    Akendo Guest

    I wanted to reply to this post, but it has gone to far. So i pushed it out on a blog post.
  12. arcteryx

    arcteryx Guest

    upload files in folder

    I have a question, I've seen this command before and have been trying it out by uploading multiple files in a folder and was unsuccessful. Would this be possible to work? I tried the command with a recursive '-R' and a wildcard at the end of the directory.

  13. user

    user Guest

    I am sorry to reply something unrelavant to your post. But I need help.
    I don't know how to create new post. I look everywhere, But find no such a button to create new post. Please help!
  14. -R is not -r. Most Linux developers don't allow case insensitivity in user input.

    What's an example of your command?

    There's an orange button right around where the Reply To Thread button is. You have to be inside one of the main forums.
  15. Mohanasmith

    Mohanasmith Guest

    its really complicated one to understand, making me frustated now, i dont think it an easy one to go through
  16. Maverick1

    Maverick1 Guest

  17. I'm trying to copy files from my laptop to my server in the basement with this command and it won't work. Perhaps you could give me some advice? Below is the command I've tried:

    sudo scp /home/brandon/Documents/3011.jpg [email protected]:/var/www/brandon-PC/

    It always tells me the following:

    The authenticity of host ' (' can't be established. ECDSA key fingerprint is 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00. Are you sure you want to continue connecting (yes/no)?

    And every time I say "y" it just asks me again and again and again and again...

    Please tell me what I'm doing wrong.

    Brandon Doyle

Share This Page