ssh to non-22 not working, edited sshd_config and restarted sshd
Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
ssh to non-22 not working, edited sshd_config and restarted sshd
So according to at least three sites I've been to, all I should need to do is edit the one line in sshd_config to another port (29 in this case, which is unused) and restart sshd. I've set my router to port forward to 29 on my server. 22 works. 29 works when I ssh locally but not from another computer on the internal network or from outside. using Fedora 12. Help?? Tanx in advance.
Thanx, I did now change port from 9222 to 29 in config file, missed that. restarted sshd, failed to stop. going back to 9222. restarts ok but no ssh. Thanks for the quick replies, all...
Thanx, I did now change port from 9222 to 29 in config file, missed that. restarted sshd, failed to stop. going back to 9222. restarts ok but no ssh. Thanks for the quick replies, all...
Am I assuming correctly that this is not fixed?
If so (as root user):
- Stop the sshd daemon,
- Change the port/listenaddress,
- Start sshd daemon.
Can you post the output of the following command (as root user): egrep -i "listen|port" /etc/ssh/sshd_config
Druuna, you assume correctly, not fixed. I did what you said. Stopped daemon, changed port, started daemon. Here's what my file looks like:
#Port 22
Port 9222
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::
I also want to ask you about your use of egrep as, though I'm not a noob, I'm not a fecking expert and had to google egrep. Was your use of a pipe in "listen|port" a logical OR? it seems to be because anything with either "listen" or "port" was returned. Any education on the use of egrep would be bonus. here is my output from egrep, though it's the same as my paste above: [root@Dysnomia ssh]# egrep -i "listen|port" /etc/ssh/sshd_config
#Port 22
Port 9222
#ListenAddress 0.0.0.0
#ListenAddress ::
Druuna, you assume correctly, not fixed. I did what you said. Stopped daemon, changed port, started daemon. Here's what my file looks like:
#Port 22
Port 9222
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::
It isn't clear to me if you want to use port 29 as mentioned in your first post or port 9222 as shown in the above output. But either should work, even if the content of the sshd_config file is very minimalistic.
You mention that this is not fixed, what exactly do you mean by that? Assuming you want to use port 29 and changed the sshd_config file accordingly; Are you able to use ssh locally (I.e: ssh -p 29 localhost and ssh -p a.b.c.d and/or are you able to access this box from another box?
If you can ssh locally it proves that the sshd daemon is listening and working. You can make sure by checking with this command: netstat -pln | grep ssh.
If you cannot access this box from a remote box you might have a firewall in place that needs to be changed (it probably allows access to/from port 22, but not any other port).
Quote:
I also want to ask you about your use of egrep as, though I'm not a noob, I'm not a fecking expert and had to google egrep. Was your use of a pipe in "listen|port" a logical OR? it seems to be because anything with either "listen" or "port" was returned.
The part between the double quotes is a regular expression and thus the | is seen as an OR. Grep normally only takes 1 pattern, using egrep (or grep -E) tells grep that an extended regular expression is being used. Have a look at man grep, especially the REGULAR EXPRESSIONS section.
Thanks to everyone who gave assistance on this. It was COMPLETELY UNECESSARY however. I'm surprised no one asked "why are you doing this?" All i wanted to do is ssh to more than one box from the outside when all I need to do to accomplish this is remote into one and from there, remote to the other. No need for more than one port on firewall. >< Hey, at least I learned egrep, thanx!
Just to note, that you could also create a tunnel between the final machine and the local one, in case you want to copy something between these two without copying it first to the machine in the middle. The -L option to ssh will do it.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.