Welcome to WebmasterWorld Guest from 54.198.87.238

Forum Moderators: phranque

Message Too Old, No Replies

[SSH] 'service sshd restart' doesn't work when logged in as non-root

     
12:37 am on Aug 5, 2010 (gmt 0)

10+ Year Member



Hi there,

I am trying to harden SSH logins on a CentOS dedicated server and noticed that:

1) when I set:

PermitRootLogin no
AllowUsers thatuser


in /etc/ssh/sshd_config

and

2) login SSH with that non-root user and su as root (I also check that I'm root with whoami and see that i am root)

I noticed that i.e. a command like service sshd restart gives:

service sshd restart
bash: service: command not found
error,

but /etc/init.d/sshd restart works.. that's OK, but why on earth 'service sshd restart' doesn't work?

Anybody?
2:02 am on Aug 5, 2010 (gmt 0)

WebmasterWorld Senior Member lammert is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



If you do a "su" command, the login scripts of the new user level are not parsed and all environment variables are inherited from the previous user. The root user needs some extra directories added to the PATH environment variable to be able to execute privileged commands.

The correct way to become root with all necessary settings is "su -" which causes the new shell to execute the login scripts for user root.
4:39 am on Aug 5, 2010 (gmt 0)

10+ Year Member



Wow! Great! really appreciated..
thanks.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month