The whole idea of ssh-agent
is to enable you to add your keys and passphrases once so you won't have to type them again as long as the machine is running. You don't need to run ssh-add
in your bashrc
- you only need to run it once in your shell to type the passphrase, and as long as your ssh-agent
is running, it will keep the decrypted key in it's memory and you won't have to type the passphrase again. You only need to keep the eval $(ssh-agent -s)
line in your bashrc
.
The reason it asks for a passphrase in the first place, is that when you create a new ssh key (using ssh-keygen
), it asks the user for a passphrase. You can leave it empty to indicate that you don't want to encrypt your key, but if you do type a passphrase, you'll have to type it any time you'd want to use the key in the future (again, that's exactly where ssh-agent
comes in handy).
The difference between you and your friend is that your ssh key is probably protected by a passphrase, and your friend's key is not.
As @FelixJN wrote in the comment, you can run ssh-keygen -y -f ~/.ssh/id_rsa
to confirm it asks for a passphrase. If your friend runs it, it probably won't ask for it because his key is not encrypted.
ssh-keygen -y -f ~/.ssh/id_rsa
prompt for a password? If so, you would need to unencrypt or pass the password via a script (insecure). – FelixJN Jan 17 '22 at 12:58