0

I am connecting to machine via ssh key and have sudo rights. How can I check that username password I know is correct?

/etc/shadow doesnt' contain me.

What else can be done?

Stephen Kitt
  • 411,918
  • 54
  • 1,065
  • 1,164
Dims
  • 3,181
  • 9
  • 49
  • 107
  • Rename your local SSH key temporarily and try to login with your password. And if your system doesn't allow password-based authentification why should you worry? – xenoid Nov 19 '19 at 08:17
  • @xenoid The question is "what else can be done?" and your comment looks like an answer. – Kamil Maciorowski Nov 19 '19 at 08:20

2 Answers2

6

Invoke passwd. You should be asked your current password; provide the password you know.

Wrong password will make the command fail immediately. Correct password will allow you to set a new password. Set a new password by typing it twice or deliberately type two different strings to leave the password unchanged.


Does su "$USER" ask for a password? It may not but if it does, provide the password you know.

Wrong password will make the command fail with Authentication failure. Correct password will give you a shell (exit it with exit).

Kamil Maciorowski
  • 19,242
  • 1
  • 50
  • 94
2

You might be using directory services and not be using a local account. In that case you won't find an entry in /etc/shadow.

Check passwd entry in /etc/nsswitch.conf for that.

It is possible to skip key authentication with SSH using

ssh -o "PubkeyAuthentication=no" <host>

This way you can try to login with your password*

*) if other authentication mechanisms are not in place. Otherwise you can use -o "PreferredAuthentications=password" to force password authentication

Lambert
  • 12,495
  • 2
  • 26
  • 35