Wednesday, April 24, 2024
 Popular · Latest · Hot · Upcoming
8
rated 0 times [  8] [ 0]  / answers: 1 / hits: 4718  / 2 Years ago, tue, may 24, 2022, 2:09:28

I accidentally did ssh-add -d, trying to remove a certain key but it removed all of them from my ssh-agent. Do I need to re-add my key from authorized_keys or will it automatically happen next time I login with ssh -i me@wherever?



I'm afraid to logout and then be locked out of the system.



I tried typing ssh-add /home/me/.ssh/authorized_keys but then it asks for a passphrase and I don't know what passphrase it's talking about.


More From » ssh

 Answers
7

ssh-add is the client part of ssh-agent, it has nothing to do with granting access to hosts (which is done by adding the public key (.pub) to ~/.ssh/authorized_hosts on the server side). ssh-agent is a program which you use on the client side, the server side only needs sshd.



By invoking ssh-add -d, you have cleared a cached key from ssh-agent such that you have to re-enter your SSH keyfile passphrase next time you ssh to a system. You won't lock yourself out by clearing this cache. Simply run ssh-add (or ssh-add ~/.ssh/id_rsa for a specific keyfile) to remember the keyfile passphrase again for this session.



The -i option of ssh is only necessary if your private key is located on a non-standard location. ssh -i ~/.ssh/id_rsa user@host is nearly equivalent to ssh user@host since ~/.ssh/id_rsa is one of the standard places where SSH looks for a keyfile.



The reason why ssh-add ~/.ssh/authorized_keys prompts for a password is because it did not recognize an unprotected key, and thus assumed a password-protected key. In fact, the file has an invalid format so no password will work here.



See also the manual page ssh-add(1).


[#24354] Wednesday, May 25, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
hamostic

Total Points: 403
Total Questions: 142
Total Answers: 112

Location: Iceland
Member since Sat, Sep 17, 2022
2 Years ago
;