0

I have followed the process of creating the public and private keys so that I can login in to remote system without a password.

But I would like to login into the remote system as root user without password using SSH keys.

For example, vm2$ssh vm1@10.0.0.1 would give me vm1$ prompt but I need ssh vm1@10.0.0.1 to give me vm1#.

Is this possible?

0

Yes you can, though this is not a recommended setup.

To login as root user, you need to specify that you want the root user. The command would be

ssh root@10.0.0.1

Of course, this only logs in, so in order to use your keys, you have to copy them:

ssh-copy-id -i ~/.ssh/id_rsa root@10.0.0.1

You'll be prompted for password once. After that, you can SSH as the root user on 10.0.0.1 with the first command.

  • ssh-copy-id -i ~/.ssh/id_rsa root@10.0.0.1 when I am giving this command and entering the password its showing Permission Denied, please try again – karra Dec 1 '18 at 12:12
  • @karra You'll need to enter the root password, or try something else (I'll add it later). – iBug Dec 1 '18 at 12:13
  • Sorry if its naive. The password for $sudo -s and the root password are same. right ? – karra Dec 1 '18 at 12:15
  • @karra yeah it is, but you need the root password of the remote machine – iBug Dec 1 '18 at 12:16
  • yes, I am entering the remote machine password. I have even checked on the remote machine – karra Dec 1 '18 at 12:17

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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