-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
  • 535
  • 2
  • 8
  • 15
  • Possible duplicate of [What causes the 'Connection Refused' message?](http://serverfault.com/questions/725262/what-causes-the-connection-refused-message) – user9517 Apr 05 '16 at 17:03
  • @lain Please read my update. The above link did not help. I am here for help. – developer Apr 05 '16 at 17:34
  • Disdainful bigotry is all I got from you. Shame! Look at the answer I provided myself and at least learn how to read a question! Putting on a question as off-topic, I have oftentimes encountered in serverfault, is another way of evading the shame of not being able to answer a question. – developer Apr 08 '16 at 10:11
  • Actually I v-t-c as a dupe which it is. Because you were not correctly specifying the port, scp defaulted to 22. As you have nothing listening on 22 then you get the Connection Refused message. If you have read the duplicate carefully you would have learned that but hey ho lead a horse to water and all that. – user9517 Apr 08 '16 at 13:07
  • @lain. And you preferred, all condescendingly, to direct me to a post where I MAY have found the answer, rather than dropping a simple comment as "specify your port right after scp". As simple as that! And if you really wanted to help! You know, people like you tend to make life a lot more troubling than it can sometimes actually be! The good thing about such forums or websites is that you do not need to read a whole book entirely before you get the clue or the right answer to a minor problem. – developer Apr 10 '16 at 08:50
  • That's because I prefer to educate people in solving problems rather than making them lazy and dependent on other people by giving them the answer. It clearly wasn't a minor problem to you as you had to ask the internet to help you solve it. – user9517 Apr 10 '16 at 11:22
  • Your words, big brother, stinks of sophistry and arrogance! Sometimes, we do need a quick reply. Makeshift solutions and ready-made answers have their own merits at times. You should know that there are no rigid formulas as far as education is concerned! Go on justifying your mistake if you like. Double block my question. Put it on eternal hold. But remember it was only a matter of a simple comment... That's all ;) – developer Apr 10 '16 at 19:41
  • Oh dear you have it real bad don't you - the world owes you ... nothing. SF as no SLA with you and you get what you pay for. One of us has sysadmin skills and the other can only ask crappy questions of the internet. One of us can have a productive day whilst the other has to sit and wait for someone to give a little bit of their life to help them. Stop whingeing like a whiney child and row up. – user9517 Apr 10 '16 at 20:22

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
  • 535
  • 2
  • 8
  • 15
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.]

Some Linux Nerd
  • 3,157
  • 3
  • 18
  • 20