Hi I have my ssh config file setup to auto add ssh keys to ssh agent. However, currently it is not working. It was working previously. I updated the ssh key for bitbucket and it no longer works. When I reboot, I have to add the ssh key manually using ssh-add -K option.
Can someone help me figure out why ssh config isn't working? AddKeysToAgent yes option is suppose to enable the auto adding of ssh keys.
I am running macOS Sierra 10.12.4
Here is config (I changed server names for sensitivity purposes)
GSSAPIAuthentication no
# --- SourceTree Generated ---
Host cik-bitbucket__com
HostName bitbucket.com
User cik
PreferredAuthentications publickey
IdentityFile /Users/cik/.ssh/cik-bitbucket__com
UseKeychain yes
AddKeysToAgent yes
# ----------------------------
Host *
UseKeychain yes
AddKeysToAgent yes
ServerAliveInterval 15
IdentityFile /Users/cik/.ssh/id_rsa
Host jenkins
HostName pasjenkins1.mycompany.com
UseKeychain yes
AddKeysToAgent yes
Host jenkinsqa
HostName pasjenkinsqa.mycompany.com
UseKeychain yes
AddKeysToAgent yes
Host artifactory
HostName prp01
UseKeychain yes
AddKeysToAgent yes
Host bitbucket
HostName bitbucket
UseKeychain yes
AddKeysToAgent yes
Host confluence
HostName confluence01
UseKeychain yes
AddKeysToAgent yes
Host jira
HostName jira01
UseKeychain yes
AddKeysToAgent yes
Host vagrant
HostName 127.0.0.1
Port 2222
User vagrant
IdentityFile /Users/cik/.vagrant.d/insecure_private_key
Host localhost
HostName 127.0.0.1
Port 2222
User vagrant
IdentityFile /Users/cik/.vagrant.d/insecure_private_key
Update:
Order matters.
This works
ssh-add -D
ssh-add -K /Users/cik/.ssh/cik-bitbucket__com
ssh-add
git push (Works)
Does not work
ssh-add -D
ssh-add
ssh-add -K /Users/cik/.ssh/cik-bitbucket__com
git push (Works)
There are two other ways you can enable SSH for macOS devices: Turn on SSH in the GUI by going to System Preferences > Sharing > Remote Login. Leverage the Commands tab in the JumpCloud Directory Platform to enable SSH across your fleet.
ssh is a hidden folder in there but can be accessed normally via the command line. So you want something like <editor> /home/<user account name>/. ssh/config .
ssh folder hidden. To see your . ssh folder in the Finder, press Command+Shift+G, then enter ~/. ssh .
Where is the SSH configuration file? On macOS systems, the configuration file is found at “/private/etc/ssh/ssh_config,” which is symlinked to “/etc/ssh/ssh_config” for compatibility. A second, user-specific ssh_config is found at “~/.
You have got too many keys in your agent and only limited amount can be tried before rejecting by server. Fortunately, you have quite nice configuration distinguishing the keys per hosts, so you should be able to fix that by setting
IdentitiesOnly yes
configuration option in your ssh_config
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With