<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Papa Pathé SENE</title>
    <description>The latest articles on DEV Community by Papa Pathé SENE (@papepathe).</description>
    <link>https://dev.to/papepathe</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F63849%2F28af95f3-89f3-48b5-942c-781c6bd7d315.jpeg</url>
      <title>DEV Community: Papa Pathé SENE</title>
      <link>https://dev.to/papepathe</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/papepathe"/>
    <language>en</language>
    <item>
      <title>Per project git ssh keys</title>
      <dc:creator>Papa Pathé SENE</dc:creator>
      <pubDate>Tue, 28 Jul 2020 16:13:15 +0000</pubDate>
      <link>https://dev.to/papepathe/per-project-git-ssh-keys-1i6h</link>
      <guid>https://dev.to/papepathe/per-project-git-ssh-keys-1i6h</guid>
      <description>&lt;p&gt;As a professional software developer you  work on  different projects for distributed clients. &lt;/p&gt;

&lt;p&gt;You have to deal with many source code management services and ssh keys. &lt;/p&gt;

&lt;p&gt;For my case i have a professional ssh key  and a personal one. I would like to be able to just run git push or pull without specifying the ssh-key to use and git will figure out the rest.&lt;/p&gt;

&lt;h2&gt;
  
  
  First approach
&lt;/h2&gt;

&lt;p&gt;We can use the environment variable to switch the ssh-key used by git the authenticate push &amp;amp; pull requests.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;GIT_SSH_COMMAND&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"ssh -i /path/to-your/ssh-key"&lt;/span&gt; git push your-origin your-branch
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Second approach
&lt;/h2&gt;

&lt;p&gt;We all agree that it's boring to always specify the ssh key. Thanks to the community, git has a sshCommand configuration variable. We will use it and configure a per project ssh key.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;git config core.sshCommand &lt;span class="s2"&gt;"ssh -i /path/to-your/ssh-key"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://git-scm.com/docs/git#Documentation/git.txt-codeGITSSHCOMMANDcode"&gt;GIT_SSH_COMMAND&lt;/a&gt;&lt;br&gt;
&lt;a href="https://git-scm.com/docs/git-config#Documentation/git-config.txt-coresshCommand"&gt;git config sshCommand&lt;/a&gt;&lt;/p&gt;

</description>
      <category>git</category>
      <category>github</category>
      <category>ssh</category>
      <category>gitlab</category>
    </item>
  </channel>
</rss>
