Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I've used yum install nagios on an Amazon Linux instance, and it created a nagios user with shell /sbin/nologin and homedir /var/spool/nagios. This is the behaviour on EC2.

I want to use check_by_ssh running locally as user nagios to execute a command on the remote host as some user, without typing in a password. So using ssh-keygen seems logical, but how do I generate a public key for user nagios if that user doesn't have a shell?

Is the answer to change the default shell (e.g. to bash) and perhaps the homedir of local user nagios so I can generate the key, or is there another way?

  • Question: Is it bad practice to allow the nagios user to login?
  • Question: Is it bad practice to change the homedir, e.g. to /home/nagios?
  • Question: What is the recommended way of doing this?
share|improve this question
    
You can login as another user (even if that user doesn't have a shell) using su -ls /bin/bash username if you have the password (or are root). –  Ulrich Schwarz Oct 27 '11 at 17:09
    
@UlrichSchwarz: Thanks, good tip! –  Pimin Konstantin Kefaloukos Oct 27 '11 at 19:08

1 Answer 1

up vote 0 down vote accepted

Run su -c 'ssh-keygen -N ""' nagios to generate the key pair, or alternatively generate the key pair as another user then copy it in place into ~nagios/.ssh. Then run su -c 'ssh-copy-id someuser@remote-host' nagios to install the public key on the remote machine.

You can change the nagios user's home directory if you like, but I don't see the point.

There's no need to change the nagios user's shell for what you require here.

share|improve this answer
    
Would +1, but don't have the rep required yet. Thanks. –  Pimin Konstantin Kefaloukos Oct 28 '11 at 7:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.