How to retrieve ssh password with a working ssh key

No, there is no relation between an account password and the ssh key.

You can logon to an account with ssh with a key even if it has no password.


For the updated question, yes, type:

su YOURUSERNAME

then try if you remember your password


The SSH key is completely independent from the password. Knowing a key is of no help to find the password.

If you're root on the server, you can obtain the password hash. It's in /etc/shadow if it's a local account, or it may be retrieved from a network database such as LDAP. On Linux, try sudo getent shadow $USER. Once you have the password hash, you can try it offline. If you only have a few password candidates, you can use this one-liner where $6$stuff$more.stuff is the second :-separated field in /etc/shadow:

perl -l -pe '$_ = crypt $_, q:$6$stuff$more.stuff:'

If you need heavier brute-force, look up software for guided password attack. I'm not familiar enough to make a recommendation.

Of course, if you're root on the server, you can also change the password.