-4

I am trying to copy a file from my computer to my server through scp command. I have changed the default sshd port from 22 to 36871. Now, the problem is when I issue the scp command over port 36871, I get a "Connection refused" error, as it tries to connect through the default port 22. I issue the command as follow:

sudo scp /Users/developer/Desktop/file.zip -P 36871 admin@XXX.XXX.XXX.XXX:public_html

I don't have this problem when I change the port back to 22 and issue the following command:

sudo scp /Users/developer/Desktop/file.zip -P 22 admin@XXX.XXX.XXX.XXX:public_html

Update: It seems it does not have to do with my server's firewall settings. The problem is that when I issue the command with a port other than 22, my computer's firewall (Little Snitch) shows that the terminal wants to connect with port 22. In other words, the terminal does not even try the other port. I think there is a problem with the command itself. Do I need to enter the port in some other arrangement?

Any ideas would be appreciated.

Thanks

developer
  • 555

2 Answers2

2

Ok, I think I found the answer after some experimentation. I only needed to enter the remote port after scp. So here is the right command:

sudo scp -P 36871 /Users/developer/Desktop/file.zip admin@XXX.XXX.XXX.XXX:public_html
developer
  • 555
0

You probably have a port specifically configured in /etc/ssh/ssh_config. Port=XXX in the config somehow overrides -oPort=XX so I assume -P too (at least on this one machine I was using). It's actually super annoying. If its not that, check for a file called config or .config or something like that in your ~/.ssh/config file.

[Edit: Fixed file name.]