The passwords used for login
and sudo
may be the same, but the authentication mechanism behind is it different. So there is no direct way to avoid having to enter the password twice.
Things you can do to overcome this (but with their own drawbacks):
- Add your current user to
/etc/sudoers
, so you can use sudo
without having to login as another user. You would still need to enter your password whenever you use sudo
- Enable
ssh
and add the public key of current user to the authorized ssh keys of the admin user. This allows you to log in as admin
with ssh admin@localhost
, without entering a password
For the second option, do the following once you've enabled ssh
in System Preferences:
- As your normal user, run
ssh-keygen
(and just press enter on all questions)
Replace ADMIN with the name of the admin user and run
ssh ADMIN@localhost "mkdir ~/.ssh; cat >> ~/.ssh/authorized_keys" < ~/.ssh/id_rsa.pub
This will be the last time you'll need to enter the password of the admin user to log in
- Run
ssh ADMIN@localhost
to log in as the admin user