Welcome to WebmasterWorld Guest from 188.8.131.52 , register , free tools , login , search , pro membership , help , library , announcements , recent posts , open posts Become a Pro Member
[SSH] 'service sshd restart' doesn't work when logged in as non-root teasers msg:4182175 12:37 am on Aug 5, 2010 (gmt 0) 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 error, bash: service: command not found but /etc/init.d/sshd restart works.. that's OK, but why on earth 'service sshd restart' doesn't work? Anybody?
lammert msg:4182192 2:02 am on Aug 5, 2010 (gmt 0)
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. teasers msg:4182265 4:39 am on Aug 5, 2010 (gmt 0)
Wow! Great! really appreciated.. thanks.