Reputation: 14974
In ~/.ssh
I have github
and bitbucket
private key files. Both are encrypted, so when I ssh-add ~/.ssh/github
I have to enter a password.
I have a bash script to automate git
commands. If the github
and/or bitbucket
identities have NOT been added yet, then I want to ssh-add
them.
I'm looking for a function like:
has_identity_been_added ~/.ssh/github
To simply check if the private, encrypted key file has been added.
I found:
ssh-add -l
prints out a string of text for each identity... and I don't know what it is, but it's not the key file namessh-add -L
prints the public key, which I'm not storing on my local machine, so I'm not sure how to verify against it, without asking for the private key file's password again.Both of those print the name I gave to the key file like reed@laptop-x1834
(I think that was the automatic name, cause I didn't specify -C
in the ssh-keygen
, if memory serves).
I'm not sure where to go from here. I don't want to rely upon the ssh-keygen -C "whatever_name"
.
Upvotes: 5
Views: 4595
Reputation: 26397
ssh-add -l
print out fingerprint of the keys added.
You can get the fingerprint of a public key with :
ssh-keygen -l -f id_rsa.pub
Upvotes: 6