Passwordless root authentication via SSH

Hello,

I would like to issue a couple of commands as root on a remote machine without having to enter the root password. I used "ssh-keygen -t rsa" to generate the encryption keys, copied the public key to the remote machine, etc.

I also tried playing around with the sshd_config file and restarting the sshd daemon on the remote machine. I tried setting PermitRootLogin to yes, without-password, and forced-commands-only. None of these worked. I get a permission denied error when I try:
ssh root@[machine] -o PreferredAuthentications=publickey -vv

I was successful in setting up public key authentication to the same remote machine using a login other than root. However, I have to run the remote commands as root, so this does not do me too much good.

Advice would be much appreciated.

Thanks!

It just sounds like you may have a key problem

Step 1
install stup ssh and make sure it is running you can use putty or telnet to test
telnet to port 22 on remote system

Step 2
generate a key on local system ( as user required )
ssh-keygen -t rsa

Follow the on-screen instructions, but don't set a password when prompted, as you will then need to enter the password each time you want to use the key. This creates a private and a public key file.

Step 3
Now you just need to append the contents of the public key file in .ssh/id_rsa.pub, and append it to the .ssh/authorized_keys file on the remote host and user you want to use when logging in. You need to append the public key file contents to each machine you want to log in to automatically.

Note
if you want to go back to the other system make sure you create a key on each system and then just need to append the contents of the public key file in .ssh/id_rsa.pub, and append it to the .ssh/authorized_keys file

OpenSSH is now bundled with AIX

So you generated your public key on the local system using ssh-keygen...now you need to copy it to the remote system and append right?

  1. cd into /root/.ssh on your source box
  2. Use this command:

cat *.pub | ssh <hostname> "cat - >> /root/.ssh/authorized_keys"

You will read out the the contents of your rsa/dsa .pub keys, using ssh to copy and append to the destination host. After you type the password (for the last time), then try again something simple such as:

ssh <hostname> date

And if you've done everything correctly, no password.

depending on the commands you are trying to run.... sudo may be a better option.

in the target machine do visudo and add your user name (or at least the username you have the ssh keys working)

there are examples in the suders file of how to set. But this is the basic idea.

username ALL=(ALL) NOPASSWD: ALL

Just a thought.