2

For the last year I've been searching for this regularly and still haven't found an answer to my query.

I work on Ubuntu servers quite a lot, both locally (VM) and staging / production servers and I connect via Putty (I'm on Windows) all the time.

1. How do I sudo without having to enter my Linux user's password all the time?

I thought that the whole point of key-based authentication is that it's a lot safer than passwords. However as an admin, I need to sudo all the time.

I've seen it quite a lot where I've been given access to log-in as a non-root user, do sudo su (or any other sudo command) and I'm not asked for a password.

From what I've found, I've been adding richard ALL=NOPASSWD: ALL to nano /etc/sudoers. However I've also read that this is unsafe (mainly in case you leave you PC unmonitored and someone else gets root access).

I did read that if you protect your private key with a passphrase, you can have your client remember the password for you, but I'm not talking about the passphrase on the key, but the password of the user account on the server.

2. How do you go about contingency in case the PC, of the only user that has a private key, goes up in smoke?

When you enforce private key connections only, how do you get back in?

  • 1. You already know how to enable passwordless sudo. 2. Backup the private key. – AlexP Nov 18 '16 at 7:56
  • Well, 1. Would you agree that this is the best and only way to do it? 2. Not particularly safe though, having your private key "floating" around. Anyone that gets their hands on it has full access to the server, including ability to change the public key... – Richard Nov 18 '16 at 8:07
1
  1. Use the NOPASSWD tag in your /etc/sudoers policy file just like you found. Make sure, then, that you don't leave your PC unmonitored while logged-in. However, it's safer to have a sudo password (which is different from your login password—in which you are right in that it's safer to use asymmetric encryption for log-in, ie. key-based authentication).
  2. As @AlexP suggests, backup your private key. I recommend that you store it in a CD/DVD and keep it in a safe place. This minimizes the chances that an intruder will get their hands on it.

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.