LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Security (https://www.linuxquestions.org/questions/linux-security-4/)
-   -   Wierd happenings when securing SSH (https://www.linuxquestions.org/questions/linux-security-4/wierd-happenings-when-securing-ssh-370053/)

mattp 10-05-2005 01:08 PM

Wierd happenings when securing SSH
 
I am trying to configure my SSH (on my slack 10.2 box) to deny login from ROOT and to allow login only from user "phonehome"

Here are the relevant lines I have in my /etc/ssh/sshd_config:

PermitRootLogin no
AllowUsers phonehome

Why can I still login from root?

I have tried killing the SSHD process with no luck. What am I doing wrong?

anomie 10-05-2005 02:13 PM

Quote:

I have tried killing the SSHD process with no luck. What am I doing wrong?
So I take it you have not restarted sshd? After changing sshd_config you will need to.

The SuSE way is
Code:

sshd restart
or
Code:

/etc/init.d/sshd restart
The FreeBSD way (that I use anyway) is issuing a kill to sshd and then starting it again.

One of these should work on slackware (although your sshd script path will probably differ). So you can tinker some more or wait for a slackware expert to see this.

mattp 10-05-2005 02:15 PM

No, actually I did restart it. I did a "kill [proc id]". It restarted on its own and still didn't work.

I am issueing all of these commands from work over the SSH if that makes any difference.

anomie 10-05-2005 02:35 PM

Quote:

Why can I still login from root?
Just to be sure I'm really understanding this question, are you using
Code:

ssh root@host_name
and it is still working? Or are you logging in via ssh as another user and then su-ing to root?

mattp 10-05-2005 02:36 PM

I am using PUTTY from winxp. I ssh to my IP, it says LOGIN: I type root then the PW when it asks and BANG- Im in.

anomie 10-05-2005 02:42 PM

Totally strange. All I can think of is 1) sshd was not really restarted; or 2) the 'PermitRootLogin no' is not being parsed by the sshd script correctly because of an extra character or something.

Very curious to see the resolution for this one....

Hangdog42 10-05-2005 04:47 PM

Quote:

Originally posted by mattp
No, actually I did restart it. I did a "kill [proc id]". It restarted on its own and still didn't work.

I am issueing all of these commands from work over the SSH if that makes any difference.

The first bit doesn't make any sense. Unless you rebooted, Slack isn't going to restart a daemon on its own. Try running /etc/rc.d/rc.sshd restart and see if that causes sshd to pick up the new setting.

mattp 10-05-2005 05:30 PM

Well, I was doing all of this editing thru SSH. I did Kill [Proc ID], and my connection was terminated. I tried logging in again as root and was successfull. I did ps -e and sshd had a new proc id. I supose this means that SSHD was restarted.

I guess I will have to physically look at the box when I get home.

Hangdog42 10-06-2005 07:10 AM

I'm guessing here, but I bet that you just killed the ssh session you were using at the time, not the ssh daemon. If you had actually killed sshd with kill, you absolutely shouldn't have been able to reconnect via ssh unless you've got some other program monitoring sshd and starting it up again if it dies.

By the way, if you us the restart command in my previous post, it actually will maintain the ssh connections in use. The way you did it, you would need physical access to the machine to restart sshd.

mattp 10-06-2005 07:27 AM

Oh cool! I will try again from SSH in a little bit!

mattp 10-06-2005 09:41 AM

Some how I locked my self completely out of SSH. I need to get on the box physically and reconfig sshd_config to allow my user!

mattp 10-06-2005 11:26 PM

Okay, I recommented out AllowRootLogins no just see if I can get the SSHD config to take changes when I use them. I restarted SSHD by doing:

rc.sshd stop
rc.sshd restart

and it still denies all users (root included)

Then I did

rc.sshd stop
rc.sshd start

Same thing. How do I get SSHD to take my changes!!!!??

|2ainman 10-07-2005 05:26 AM

handog is right. Also ...
from sshd manpage:
sshd rereads its configuration file when it receives a hangup signal,
SIGHUP, by executing itself with the name and options it was started
with, e.g., /usr/sbin/sshd.

You could also edit your rc.sshd under the sshd_start function and add the -d parameter for debugging output

Hangdog42 10-07-2005 07:00 AM

If ssh is no longer allowing anyone in, you're going to have to dig through your logs (/var/log/messages and /var/log/syslog) to find some clues as to why. Even without the -d flag, ssh usually leaves some clue as to what is happening.


All times are GMT -5. The time now is 08:39 AM.