homepage Welcome to WebmasterWorld Guest from 174.129.163.183
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld

Home / Forums Index / WebmasterWorld / Webmaster General
Forum Library, Charter, Moderators: phranque & physics

Webmaster General Forum

    
[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
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?

 

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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / WebmasterWorld / Webmaster General
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved