1

I have server 1 running aix configured at 192.168.0.1 and and another Linux server configured at 192.168.0.2. I am currently using expect to login as root@192.168.0.2.

The problem is that the process running expect aborts because it is a background process and once it hits the input for username it thinks it is at a stop. I wanted to install keys so that it will not prompt for the password and I can do away with expect.

I read how to install the keys, but am confused. I am logged into 192.168.0.1 as user1 not root and will be running the ssh command using using user1 and not root.

Do I create the keys as root or user1 on 192.168.0.1? I want to be logged in as user1 on 192.168.0.1 and do ssh root@129.168.0.2 without password prompting.

Bill
  • 136
  • 12
user999684
  • 165
  • 1
  • 1
  • 8

1 Answers1

1

You are on the right track, and I think you were almost there. Yes, you can do exactly what you are wanting to do. Just make sure you put the public key on the remote host in the correct directory. You can find the directory in your /etc/ssh/sshd_config file. It should look something like this:

AuthorizedKeysFile      /etc/ssh/keys/authorized_keys.%u

More commonly the keys will be found in ~/.ssh. There are many great tutorials on setting up password-less logins. This one is not bad. This link is another good one aimed at AIX and Linux.

One last thing, it is good practice to use a passphrase when generating your key pair.

Bill
  • 136
  • 12
  • Ok, but what is the "correct directory" and do I generate i the key with the root or user1 accounts? – user999684 Nov 08 '17 at 14:31
  • All systems can be different, but as I said, you can find the directory setting in your sshd_config file. The one I gave above is just an example I copied from one of my own servers. Typically they would be in the .ssh sub directory in the user's home directory. I will edit my answer and add another link that might help. – Bill Nov 08 '17 at 14:45