EvilZone

Hacking and Security => Hacking and Security => : lucid September 17, 2013, 07:00:38 AM

: Changing default port OpenSSH
: lucid 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.

:
[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.
: Re: Changing default port OpenSSH
: frog 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.
: Re: Changing default port OpenSSH
: Stackprotector September 17, 2013, 10:16:00 AM
Yes the only thing i had to change/add was Port xxx to sshd_config
: Re: Changing default port OpenSSH
: proxx 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.

: Re: Changing default port OpenSSH
: lucid 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.

:
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.
: Re: Changing default port OpenSSH
: Stackprotector 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.

:
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
: Re: Changing default port OpenSSH
: proxx September 18, 2013, 12:20:15 PM
+1 for feyodor.
: Re: Changing default port OpenSSH
: lucid 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.
: Re: Changing default port OpenSSH
: Xtatics 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!
: Re: Changing default port OpenSSH
: lucid September 24, 2013, 07:21:12 AM
Fun stuff!

Certainly is.