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.
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
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.