3

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?
  • 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
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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