Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Scp in terminal to copy something from my laptop to a server

  1. Apr 14, 2016 #1
    Hi I need to copy something from my laptop to a server. I tried using scp filename servername but it didn't work. I asked someone and he said I have to use -P but I don't know how. I tried several ways but all of them give
    port 22: Connection refused. What can I do?
    Thank you!
  2. jcsd
  3. Apr 14, 2016 #2
    check to see if you can ssh into the device first.
    $ ssh username@ip-address

    are you able to successfully ssh into the device?
  4. Apr 14, 2016 #3


    Yes, I am able to connect, but I need to use ssh -p 4410 username@ip-address. I tried using -P and 4410 in scp command but it still didn't work.
  5. Apr 14, 2016 #4
    Try the following
    $ scp -vP 4410 username@ip-addr:/path/to/file .

    I added the verbose option, hopefully we see where it's going wrong
  6. Apr 14, 2016 #5
    Wait, so in this, where I specify the file I want to send, before or after -vP 4410? (I want to send the file from my computer to username@ip...)
  7. Apr 14, 2016 #6
    In that case
    scp -vP 4410 /path/on/your/computer username@ip-addr:/destination/path/on/remote/system/
  8. Apr 14, 2016 #7
    I get this
    usage: scp [-12346BCEpqrv] [-c cipher] [-F ssh_config] [-i identity_file]

    [-l limit] [-o ssh_option] [-P port] [-S program]

    [[user@]host1:]file1 ... [[user@]host2:]file2
  9. Apr 14, 2016 #8
    can you show me the command you are typing in?
  10. Apr 14, 2016 #9
    scp -vP 89418.txt username@ip-adr (username and ip-adr are the same i use for the ssh command which is working)
  11. Apr 14, 2016 #10
    You have to specify the port number before the text file.

    scp -vP 4410 89418.txt username@ip-adr
  12. Apr 14, 2016 #11
    You mean 4410? Isn't is already before the text file?
  13. Apr 14, 2016 #12
    yes, you didn't have it in your post.
  14. Apr 14, 2016 #13
    Sorry I am a bit confused. What do you mean
  15. Apr 14, 2016 #14
    The command you are using does not specify a destination port number. As a result, scp is using the default ssh port 22.

    Your command:
    scp -vP 89418.txt username@ip-adr

    Correct command
    scp -vP 4410 89418.txt username@ip-adr:/path/to/destination/folder/
  16. Apr 14, 2016 #15
    Oh, sorry I have that I just didn't add show it here. I have the /path/to/destination/folder/ part
  17. Apr 14, 2016 #16
    That is the correct format and should work. What is the debug output from the command?
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted

Similar Discussions: Scp in terminal to copy something from my laptop to a server
  1. My laptop (Replies: 6)