All I want to do is move a file from my laptop to my server. Both machines have openssh-server installed, and port 2222 is specified in both sshd_config files as well as both ssh_config files. I'm using the following to attempt to copy the file:

scp -P 2222 user1@thenameofmylaptop:file.name user2@[serverIPaddress]:/home/user2/filepath/file.name

Even though I have password authentication set to no and rsa keys installed in both directions, it still asks me for a password. After I give it the password, it gives me the following error:

ssh: connect to host [IP address of server] port 22: Conection refused

Is there a separate config file for scp? What am I missing?

  • Are you trying to copy between two remote machines, from a third (local) machine? or are you logged into the laptop from which you are trying to copy file.name? Feb 2, 2015 at 3:08
  • I'm logged in on the laptop from shish I am copying file.name.
    – item5
    Feb 2, 2015 at 3:09
  • In that case, you don't need the user@host:/file.name syntax for the file you're trying to copy - just scp -P 2222 path/to/local/file.name user2@server:/path/to/file.name Feb 2, 2015 at 3:23

1 Answer 1


You don't need the user@host:/path/to/file.name syntax for the local file that you are trying to copy - in fact, doing so is likely causing scp to try to open a connection on port 2222 from your laptop to itself. Try just

scp -P 2222 path/to/file.name user2@[serverIPaddress]:/home/user2/filepath/file.name

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .