Reputation:
I've been having problems with gitHub's SSH Key for Mac Sierra here: https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/
I've been able to follow the steps of
ssh-keygen -t rsa -b 4096 -C "[email protected]"
eval "$(ssh-agent -s)"
However from this part onwards, nothing works
I do not understand what they mean by "modify your ~/.ssh/config
file " & the
Host *
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_rsa
ssh-add -K ~/.ssh/id_rsa
does not work on terminal either, as the results says 'no such file or directory'
I saved the key file to my Desktop folder when ssh-keygen
prompted me for a location.
Upvotes: 1
Views: 3511
Reputation: 189809
Move the key to .ssh
where it belongs, and/or create a .ssh/config
file and tell it where to look for the key.
If .ssh
doesn't exist, you have to create it first, obviously.
# Create ~/.ssh if missing
if ! [ -d "$HOME"/.ssh ], then
mkdir -p "$HOME"/.ssh
# Make it private
chmod 700 "$HOME"/.ssh
fi
# Move files from Desktop
# Assumes id_rsa* matches public and private key files,
# and no others
mv -i "$HOME"/Desktop/id_rsa* "$HOME"/.ssh
# Make them private, too
chmod go-rwx "$HOME"/.ssh/id_rsa*
# Create config file, if missing
test -e "$HOME"/.ssh/config ||
printf '%s\n' 'Host *' \
' AddKeysToAgent yes' \
' UseKeychain yes' \
' IdentityFile ~/.ssh/id_rsa' >"$HOME"/.ssh/config
You can just copy/paste these commands to the Terminal, though putting them in a file like /tmp/sshcommands
and running it with bash /tmp/sshcommands
might be slightly less jarring.
Obviously, you should read up on these commands enough to understand at least roughly what's going on here. Probably the key realization is that ssh
doesn't know you have a Desktop
folder and would not want to look there for the key even if it knew. (You could change the final IdentityFile
statement to actually change that, but really, at this point you are better off learning the standard practice.)
Upvotes: 2
Reputation: 4330
When you did an ssh-keygen
, you would have been prompted for the location to save the keys in. It is by default ~/.ssh/
. If you saved them somewhere else, you should try locate id_rsa
and then do ssh-add <path where id_rsa is>
.
Upvotes: 3