2

When I want to login as root, I usually have to type: su -l and than an interactive query starts in order to receive the password.

Is it possible to login as root without this interactive query ?

I tried the following one liners, which did not work:

  • echo "password" | su -l
  • echo "password" | xargs su -l
1
  • 1
    SSH key-based authentication? – cychoi Mar 15 '15 at 17:17
7

Yes it is possible, many ways, but some of the ways are less safe than others. There are two methods I recommend for this.

The first and easiest way is to use sudo with the nopassword option, check the sudo manpage for details.

The second (and more secure) way is to use pam (pluggable authentication modules) with a physical token. This is more complicated, but when done right it is fairly secure.

2
  • 2
    A third way is ssh to root@localhost, either without passphrase (ouch!) or with ssh-agent set up. But really, compared to echoing plaintext passwords, sudo is way more than sufficiently secure. :) – The Sidhekin Mar 15 '15 at 16:36
  • If you are already running ssh, that would be a way to do it, but there are some risks with doing so (not a lot, but some). there are also many other ways, including calife and expect. – hildred Mar 15 '15 at 20:35
0

auth without psw ssh-keygen -t dsa ssh-copy-id -i ~/.ssh/id-dsa.pub root@ip

creates a keyset an copies the public key to the given account+host. so you can login with a simple ssh root@ip without a password

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.