Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For example, I can use ssh-id-copy to get the key and login to the remote server without entering the password. Is there a similar mechanism to run as root without prompting password?

I don't know. If login with a key is sort of safe, then I argue there should be a mechanism like that for sudo. NOPASSWD is not a good solution, however.


share|improve this question

It doesn't have key infrastructure for this. You can use sudoer instead.

Create a file in /etc/sudoers.d with

sudo visudo -f /etc/sudoers.d/filename

add a line begin with your account

ubuntuman ALL=(root) NOPASSWD: ALL

save the file

use it with caution

share|improve this answer

You say:

NOPASSWD is not a good solution

But NOPASSWD is the solution. Can you clarify your question to explain what you don't like about it?

There is a separation of concerns here: authentication is separated from authorization. Once you have proved to the system that you are who you say you are (by logging in), sudo is responsible for restricting what you can do.

The sudoers file syntax is pretty sophisticated (if somewhat arcane). You can restrict individual users (or groups of users) to certain sets of commands, with or without passwords. Would that help alleviate your concerns?

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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