Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

Thanks.

share|improve this question
add comment

2 Answers 2

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
add comment

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
add comment

Your Answer

 
discard

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.