M BUZZ CRAZE NEWS
// general

I'm specifying the port when I use scp, but I get an error saying port 22 connection refused. What am I doing wrong?

By John Parsons

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?

3

1 Answer

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

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy