{"id":2722,"date":"2012-04-28T05:53:59","date_gmt":"2012-04-28T05:53:59","guid":{"rendered":"http:\/\/www.gubatron.com\/blog\/?p=2722"},"modified":"2012-04-28T05:53:59","modified_gmt":"2012-04-28T05:53:59","slug":"add-ssh-identities-to-your-ssh-agent-when-you-start-your-bash-session","status":"publish","type":"post","link":"https:\/\/www.gubatron.com\/blog\/add-ssh-identities-to-your-ssh-agent-when-you-start-your-bash-session\/","title":{"rendered":"add ssh identities to your ssh agent when you start your bash session"},"content":{"rendered":"<p>Put this somewhere on your .bash_profile<\/p>\n<p>[bash]<br \/>\nfunction addSSHIdentities() {<br \/>\n pushd ~\/.ssh<br \/>\n #add all your keys here<br \/>\n ssh-add some_private_key<br \/>\n ssh-add some_private_key_2<br \/>\n ssh-add some_private_key_3<br \/>\n  &#8230;<br \/>\n ssh-add some_private_key_N<br \/>\n popd<br \/>\n}<\/p>\n<p>function startSSHAgent() {<br \/>\n SSH_AGENT_PROCESSES=`ps aux | grep ssh-agent | grep -v grep | wc -l`<\/p>\n<p> if [ $SSH_AGENT_PROCESSES -gt 0 ]<br \/>\n then<br \/>\n   echo &quot;SSH Agent was running. Not adding identities&quot;<br \/>\n else<br \/>\n   echo &quot;Starting ssh-agent&#8230;&quot;<br \/>\n   ssh-agent<br \/>\n   echo &quot;Adding SSH Identities&quot;<br \/>\n   addSSHIdentities<br \/>\n fi<br \/>\n}<\/p>\n<p>startSSHAgent<br \/>\n[\/bash]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Put this somewhere on your .bash_profile [bash] function addSSHIdentities() { pushd ~\/.ssh #add all your keys here ssh-add some_private_key ssh-add some_private_key_2 ssh-add some_private_key_3 &#8230; ssh-add some_private_key_N popd } function startSSHAgent() { SSH_AGENT_PROCESSES=`ps aux | grep ssh-agent | grep -v grep | wc -l` if [ $SSH_AGENT_PROCESSES -gt 0 ] then echo &quot;SSH Agent was running. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[1],"tags":[1153,929],"class_list":["post-2722","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-posix","tag-ssh"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5Unzf-HU","jetpack-related-posts":[{"id":1998,"url":"https:\/\/www.gubatron.com\/blog\/startkeychain-bash-utility-to-start-ssh-agent\/","url_meta":{"origin":2722,"position":0},"title":"startKeychain &#8211; bash utility to start ssh-agent","author":"gubatron","date":"June 3, 2010","format":false,"excerpt":"For my (and your) future reference, here's a function to put on your .bashrc or .bash_profile, you can invoke it later at any time to start\/re-start your ssh-agent. [bash] function startKeychain { killall ssh-agent rm ~\/.keychain\/* keychain id_rsa HOSTNAME=`hostname` source ~\/.keychain\/${HOSTNAME}-sh } [\/bash] Then at any time, the \"command\" startKeychain\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":593,"url":"https:\/\/www.gubatron.com\/blog\/ssh-add-l-cannot-connect-to-your-agent\/","url_meta":{"origin":2722,"position":1},"title":"ssh-add -l -> Cannot connect to your agent.","author":"gubatron","date":"September 21, 2007","format":false,"excerpt":"keychain not working for ya... you run ssh-agent but ssh-add won't add the keys. This is probably because your SSH_AGENT_PID and SSH_AUTH_SOCK variables are incorrect... so I recommend you put something like this on your .bashrc to initialize your ssh-agent correctly: export SSH_AGENT_PID= export SSH_AUTH_SOCK= #make sure no old agents\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1457,"url":"https:\/\/www.gubatron.com\/blog\/map-commands-to-servers-via-ssh\/","url_meta":{"origin":2722,"position":2},"title":"Quick N Dirty way to Map Commands to remote servers via ssh","author":"gubatron","date":"October 10, 2009","format":false,"excerpt":"You may be running several independent but similar servers at the same time and wasting time by executing commands in all of them one by one. Wouldn't it be nice to send a command to all of them at once? or to monitor all of them at once. The following\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":481,"url":"https:\/\/www.gubatron.com\/blog\/svn-cant-create-tunnel-the-system-cannot-find-the-file-specified\/","url_meta":{"origin":2722,"position":3},"title":"svn: Can&#8217;t create tunnel: The system cannot find the file specified.","author":"gubatron","date":"March 15, 2007","format":false,"excerpt":"I was trying to checkout a project from a subversion repository using Eclipse's Subversive, and I was having problems with a subversion url that starts with \"svn+ssh:\/\/\" This means all the transport has to be done using a \"ssh\" agent. Eclipse's Subclipse plugin was giving me the error: svn: Can't\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3150,"url":"https:\/\/www.gubatron.com\/blog\/how-to-add-an-existing-git-repository-to-github\/","url_meta":{"origin":2722,"position":4},"title":"How to add an existing GIT repository to github.","author":"gubatron","date":"August 31, 2013","format":false,"excerpt":"Most of the times, it makes more sense to start working on something that slowly transforms into the beginning of a project that deserves to be on github. This post is about creating a local repository and putting it on github. 1. First we must convert the main local folder\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":4122,"url":"https:\/\/www.gubatron.com\/blog\/screw-configuring-gpg-to-sign-git-commits-do-it-with-your-same-ssh-key-like-this\/","url_meta":{"origin":2722,"position":5},"title":"Screw configuring GPG to sign git commits, do it with your same SSH key like this","author":"gubatron","date":"January 30, 2025","format":false,"excerpt":"GPG gives a lot of shit on macos for some reason. It's best to just add the same SSH authentication key you have on github as a \"Signing Key\" in your github account signing configuration. Go to Settings > SSH and GPG Keys You can then configure your github client\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2025\/01\/ssh_sign.jpg?fit=736%2C441&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2025\/01\/ssh_sign.jpg?fit=736%2C441&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2025\/01\/ssh_sign.jpg?fit=736%2C441&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2025\/01\/ssh_sign.jpg?fit=736%2C441&ssl=1&resize=700%2C400 2x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/2722","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/comments?post=2722"}],"version-history":[{"count":1,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/2722\/revisions"}],"predecessor-version":[{"id":2724,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/2722\/revisions\/2724"}],"wp:attachment":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/media?parent=2722"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/categories?post=2722"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/tags?post=2722"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}