Author Topic: Changing default port OpenSSH  (Read 1786 times)

0 Members and 1 Guest are viewing this topic.

Offline lucid

  • #Underground
  • Titan
  • **
  • Posts: 2683
  • Cookies: 243
  • psychonaut
    • View Profile
Changing default port OpenSSH
« on: September 17, 2013, 07:00:38 am »
So I've edited /etc/ssh/sshd_config and changed the default port to 13409 and restarted sshd.service file. I've also copied /lib/systemd/system/sshd.socket to /etc/systemd/system/sshd.socket and changed the ListenStream as per the Arch wiki.

Code: [Select]
[Unit]
Conflicts=sshd.service
Wants=sshdgenkeys.service

[Socket]
ListenStream=13409
Accept=yes

[Install]
WantedBy=sockets.target



Then I went to my other computer and tried to connect:

ssh -p 13409 user@host
 
But it said connection refused. Sorry for the brief nature of this post. I wasn't really sure how much information was really needed.
« Last Edit: September 17, 2013, 07:02:24 am by lucid »
"Hacking is at least as much about ideas as about computers and technology. We use our skills to open doors that should never have been shut. We open these doors not only for our own benefit but for the benefit of others, too." - Brian the Hacker

Quote
15:04  @Phage : I'm bored of Python

Offline frog

  • Knight
  • **
  • Posts: 232
  • Cookies: 16
    • View Profile
Re: Changing default port OpenSSH
« Reply #1 on: September 17, 2013, 09:35:29 am »
Sounds like you need to edit the config file differently and then restart your ssh daemon. Edit /etc/ssh/sshd_config by adding 'Port xxx' and then restarting your daemon with `systemctl restart sshd.service`.

If you have two Port entries the service will listen on all ports designated so if you want to use one port exclusively make sure there is only one port entry in the config file.

Offline Stackprotector

  • Administrator
  • Titan
  • *
  • Posts: 2515
  • Cookies: 205
    • View Profile
Re: Changing default port OpenSSH
« Reply #2 on: September 17, 2013, 10:16:00 am »
Yes the only thing i had to change/add was Port xxx to sshd_config
~Factionwars

Offline proxx

  • Avatarception
  • Global Moderator
  • Titan
  • *
  • Posts: 2803
  • Cookies: 256
  • ФФФ
    • View Profile
Re: Changing default port OpenSSH
« Reply #3 on: September 17, 2013, 10:40:41 am »
Sometimes it helps to ssh to yourself before trying another machine.
Just do ssh localhost -p xxx.
Than try another machine.
See if netstat reports listening ports and try some nmap.

Wtf where you thinking with that signature? - Phage.
This was another little experiment *evillaughter - Proxx.
Evilception... - Phage

Offline lucid

  • #Underground
  • Titan
  • **
  • Posts: 2683
  • Cookies: 243
  • psychonaut
    • View Profile
Re: Changing default port OpenSSH
« Reply #4 on: September 18, 2013, 12:27:21 am »
Well, I've run an nmap scan and it shows that all ports on my device are closed.

Code: [Select]
Nmap scan report for 192.168.1.37
Host is up (0.000010s latency).
All 1000 scanned ports on 192.168.1.37 are closed

EDIT: I just figured it out. I forgot to change the port forwarding settings on the router. I originally had it forwarding all traffic over port 22 to my IP address, and I forgot to change the port number. All works now, thanks.
« Last Edit: September 18, 2013, 12:28:21 am by lucid »
"Hacking is at least as much about ideas as about computers and technology. We use our skills to open doors that should never have been shut. We open these doors not only for our own benefit but for the benefit of others, too." - Brian the Hacker

Quote
15:04  @Phage : I'm bored of Python

Offline Stackprotector

  • Administrator
  • Titan
  • *
  • Posts: 2515
  • Cookies: 205
    • View Profile
Re: Changing default port OpenSSH
« Reply #5 on: September 18, 2013, 11:53:37 am »
Well, I've run an nmap scan and it shows that all ports on my device are closed.

Code: [Select]
Nmap scan report for 192.168.1.37
Host is up (0.000010s latency).
All 1000 scanned ports on 192.168.1.37 are closed

EDIT: I just figured it out. I forgot to change the port forwarding settings on the router. I originally had it forwarding all traffic over port 22 to my IP address, and I forgot to change the port number. All works now, thanks.
Gratz :D Sure do that next time before you change settings. Next time you hide your own server behind a firewall :P
~Factionwars

Offline proxx

  • Avatarception
  • Global Moderator
  • Titan
  • *
  • Posts: 2803
  • Cookies: 256
  • ФФФ
    • View Profile
Re: Changing default port OpenSSH
« Reply #6 on: September 18, 2013, 12:20:15 pm »
+1 for feyodor.
Wtf where you thinking with that signature? - Phage.
This was another little experiment *evillaughter - Proxx.
Evilception... - Phage

Offline lucid

  • #Underground
  • Titan
  • **
  • Posts: 2683
  • Cookies: 243
  • psychonaut
    • View Profile
Re: Changing default port OpenSSH
« Reply #7 on: September 18, 2013, 07:47:06 pm »
Gratz :D Sure do that next time before you change settings. Next time you hide your own server behind a firewall :P

Yeah I should have thought of that sooner, sorry for wasting people's time.
"Hacking is at least as much about ideas as about computers and technology. We use our skills to open doors that should never have been shut. We open these doors not only for our own benefit but for the benefit of others, too." - Brian the Hacker

Quote
15:04  @Phage : I'm bored of Python

Offline Xtatics

  • Serf
  • *
  • Posts: 47
  • Cookies: 0
    • View Profile
Re: Changing default port OpenSSH
« Reply #8 on: September 23, 2013, 11:25:18 pm »
Yeah I should have thought of that sooner, sorry for wasting people's time.
All good. You know I did the same thing this weekend when I forgot I changed the static IP of the PC I was trying to SSH into.  Since I had changed modems and stopped using the router as an access point, it's rules came into play. Fun stuff!
I play the role of a human on earth.

Offline lucid

  • #Underground
  • Titan
  • **
  • Posts: 2683
  • Cookies: 243
  • psychonaut
    • View Profile
Re: Changing default port OpenSSH
« Reply #9 on: September 24, 2013, 07:21:12 am »
"Hacking is at least as much about ideas as about computers and technology. We use our skills to open doors that should never have been shut. We open these doors not only for our own benefit but for the benefit of others, too." - Brian the Hacker

Quote
15:04  @Phage : I'm bored of Python