Forum
  • Search
  • Member List
  • Calendar
Hello There, Guest! Login Register — Login with Facebook

Changing ssh listening port
Thank you for your donation

Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Threaded Mode | Linear Mode
Changing ssh listening port
6th Feb, 2014, 05:47 AM
Post: #1
effemmeffe Offline
Registered
Posts: 127
Joined: Jan 2013
Reputation: 1
Changing ssh listening port
I'd like to access my raspberry from outside of my LAN so I opened a new door on my router to ssh from office.
The problem is that if I open the port 22 I get a lot of script kid poking my ssh and I'd rather not.
I want to change the default port for ssh from 22 to a higher unused one.
But I noticed that changing /etc/ssh/sshd_config has no effect. After some digging I discovered that ssh is launched by inetd with the line:
Code:
xbian@xbian ~ $ cat /etc/inetd.conf | grep ssh
ssh  stream  tcp  nowait  root   /usr/sbin/tcpd /usr/sbin/sshd -i
xbian@xbian ~ $

and the ssh port is defined in
Code:
xbian@xbian ~ $ cat /etc/services | grep ssh
ssh        22/tcp                # SSH Remote Login Protocol
ssh        22/udp
xbian@xbian ~ $

How do I change the ssh port?
Do I need to define a new service in /etc/services and launch it with inetd?

Code:
my_new_ssh        2222/tcp                # SSH Remote Login Protocol on high port
my_new_ssh        2222/udp

my_new_ssh  stream  tcp  nowait  root   /usr/sbin/tcpd /usr/sbin/sshd -i

I'm running beta2:
Code:
xbian@xbian ~ $ cat /etc/xbian_version  
1.0Beta2
xbian@xbian ~ $
Find all posts by this user
Quote this message in a reply
6th Feb, 2014, 06:13 AM
Post: #2
mk01 Offline
Registered
Posts: 2,485
Joined: Mar 2013
Reputation: 209
RE: Changing ssh listening port
there are two options:

you enable upstart job ssh_hid (this is the generally known ssh running through its own daemon (sshd running all the time). then /etc/ssh/sshd_options is fully working like before.

second option is almost like you did. the only problem would be that if you create new service name (my_new_ssh) the "ssh" service wont get recognised for system tools & xbian-config - as they all expect ssh.

so don't be afraid to change /etc/services by directly editing "ssh 22/tcp" to "ssh 2222/tcp:".

Please read rules and do a search before you post! . FAQs . How to post log file? . Looking for answers? Please start here
Find all posts by this user
Quote this message in a reply
6th Feb, 2014, 07:33 AM
Post: #3
effemmeffe Offline
Registered
Posts: 127
Joined: Jan 2013
Reputation: 1
RE: Changing ssh listening port
Ok, thanks.
How do I restart inetd?
I tried sudo /etc/init.d/inetd restart but there is no inetd in init.d...
Find all posts by this user
Quote this message in a reply
16th Mar, 2014, 08:07 PM
Post: #4
mk01 Offline
Registered
Posts: 2,485
Joined: Mar 2013
Reputation: 209
RE: Changing ssh listening port
once again, init.d was migrated to upstart (/etc/init)

service names are files you will see in that dir without .conf suffix.

inetd is "openbsd-inetd"

so
Code:
restart openbsd-inetd

init.d is still processed as part of backward compatibility (but slowly all is moving away - out of this old concept).

Please read rules and do a search before you post! . FAQs . How to post log file? . Looking for answers? Please start here
Find all posts by this user
Quote this message in a reply
17th Mar, 2014, 09:02 PM
Post: #5
Skywatch Offline
Registered
Posts: 1,018
Joined: Mar 2013
Reputation: 28
RE: Changing ssh listening port
Thanks!

I've been trying for weeks to get back to my 'usual' ssh port configuration!

Skywatch.
Find all posts by this user
Quote this message in a reply
« Next Oldest | Next Newest »
Post Reply 


  • View a Printable Version
  • Send this Thread to a Friend
  • Subscribe to this thread
Forum Jump:

Current time: 28th Mar, 2023, 08:56 AM Powered By MyBB, © 2002-2023 MyBB Group.