<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>emre şahin's digital garden 🍃 - SSH</title>
    <link>https://emresahin.net/tags/ssh/</link>
    <description>Posts in the SSH tag</description>
    <language>en</language>
    <managingEditor>contact@emresahin.net (Emre Şahin)</managingEditor>
    <lastBuildDate>Tue, 15 Sep 2026 19:46:32 +0000</lastBuildDate>
    <atom:link href="https://emresahin.net/tags/ssh/rss.xml" rel="self" type="application/rss+xml"/>
    <item>
      <title>Xvc Devlog - 221109</title>
      <published>2022-11-10T09:26:00+00:00</published>
      <updated>2022-11-10T09:26:00+00:00</updated>
      <author>Emre Şahin</author>
      <pubDate>Thu, 10 Nov 2022 09:26:00 +0000</pubDate>
      <link>https://emresahin.net/xvc-devlog---221109/</link>
      <guid isPermaLink="true">https://emresahin.net/xvc-devlog---221109/</guid>
      <description>🐇 How do you want to proceed from here, Mr. 🐢? 🐢 I think I can implement Rsync today. Looking at ssh2-rs , though, I think we can implement file transfer without relying on rsync . It might be easier to implement everything within the code. 🐇 Then you should rename the issue to new ssh . 🐢 Fair. ...</description>
      <category>devlog</category>
      <category>development</category>
      <category>xvc</category>
      <category>ssh</category>
      <category>rsync</category>
      <category>storage</category>
      <category>feature-flags</category>
      <category>rust</category>
      <category>libssh2</category>
      <content:encoded><![CDATA[<p>🐇 How do you want to proceed from here, Mr. 🐢?</p>
<p>🐢 I think I can implement Rsync today. Looking at <a href="https://docs.rs/ssh2/latest/ssh2/">ssh2-rs</a>, though, I think we can implement file transfer without relying on <code>rsync</code>. It might be easier to implement everything within the code.</p>
<p>🐇 Then you should rename the issue to <code>new ssh</code>.</p>
<p>🐢 Fair. There is also the <a href="https://docs.rs/ssh-rs/0.2.2/ssh_rs/">ssh_rs</a> crate, but it doesn’t have full support for the protocol. Instead, we can have another command, like <code>xvc storage new ssh</code>, that uses <code>libssh2</code> via the crate mentioned above. It has some limitations with OpenSSH on macOS.</p>
<p>🐇 From the <a href="https://github.com/alexcrichton/ssh2-rs">crate’s README</a>, it looks like you can enable the <code>vendored-openssl</code> feature to compile it statically.</p>
<p>🐢 Let’s go ahead then. It’s better to compile it behind a feature flag, though.</p>
<p>🐇 Yup. Rsync can be separate. I think for now you can implement rsync via <code>Exec::cmd</code> and make <code>new ssh</code> a new issue.</p>
<p>🐢 I’ll copy this conversation there.</p>
<hr>
<p>🐇 Now, let’s start implementing <code>rsync</code>.</p>
<p>🐢 Do we really want to hide it behind a feature flag? It doesn’t bring any extra complexity to <code>generic</code>, for example—just using the commands and returning the errors.</p>
<p>🐇 I think so. If the user doesn’t have <code>rsync</code> on their system, they’ll just get errors. We don’t need to make the implementation optional, but the tests might be.</p>
<p>🐢 OK.</p>]]></content:encoded>
    </item>
    <item>
      <title>Using SSH Private Keys in Dockerfile aimed for Google Cloud Run</title>
      <published>2020-05-12T18:46:51+00:00</published>
      <updated>2020-05-12T18:46:51+00:00</updated>
      <author>Emre Şahin</author>
      <pubDate>Tue, 12 May 2020 18:46:51 +0000</pubDate>
      <link>https://emresahin.net/using-ssh-private-keys-in-dockerfile-aimed-for-google-cloud-run--24390/</link>
      <guid isPermaLink="true">https://emresahin.net/using-ssh-private-keys-in-dockerfile-aimed-for-google-cloud-run--24390/</guid>
      <description>I had a one-user software application that I had wanted to deploy to Google Cloud Run for some time. It was on Python 3.5, and when I updated the system it lives on, the virtual environment stopped working. It also depended on lxml-3.7 , and that particular version didn’t compile on my new stable...</description>
      <category>DevOps</category>
      <category>Docker</category>
      <category>Cloud Computing</category>
      <category>Docker</category>
      <category>Google Cloud Run</category>
      <category>SSH</category>
      <category>Security</category>
      <category>Python</category>
      <category>Bitbucket</category>
      <content:encoded><![CDATA[<p>I had a one-user software application that I had wanted to deploy to Google Cloud Run for some time. It was on
Python 3.5, and when I updated the system it lives on, the virtual environment stopped working. It
also depended on <code>lxml-3.7</code>, and that particular version didn’t compile on my new stable Debian
installation.</p>
<p>This motivated me to learn Docker and gcloud rather quickly.</p>
<p>I was able to create a new Docker container in a short time. However, as I don’t want to share my Git
SSH key publicly, I needed a way to put an SSH private key (<code>~/.ssh/id_rsa</code>) into this new container
securely, without leaving any trace.</p>
<p>I tried a few things, but in the end, I decided to do something like:</p>
<pre><code class="language-Dockerfile">FROM python:3.5-stretch as intermediate

# add credentials on build
RUN mkdir /root/.ssh/
# To use docker --build-arg, you can uncomment the following two lines and comment out the COPY line below.
# ARG SSH_PRIVATE_KEY
# RUN echo "${SSH_PRIVATE_KEY}" &gt; /root/.ssh/id_rsa
COPY application_sshkey /root/.ssh/id_rsa
RUN chmod 0600 /root/.ssh/id_rsa

# make sure your domain is accepted
RUN touch /root/.ssh/known_hosts
RUN ssh-keyscan bitbucket.org &gt;&gt; /root/.ssh/known_hosts

RUN git clone git@bitbucket.org:username/application /root/application

FROM python:3.5-stretch
COPY --from=intermediate /root/application /root/application

RUN pip3 install -r /root/application/requirements.txt

EXPOSE 9090/tcp

WORKDIR /root/application/

CMD python3 manage.py runserver 0.0.0.0:9090
</code></pre>
<p>Here, <code>application_sshkey</code> is a file I created using <code>ssh-keygen</code> and granted read-only access to on
Bitbucket.</p>
<p>As you can see, the Dockerfile has two <code>FROM</code> statements. It creates a container to clone the
application repository. Then it starts again with a new container and copies the repository to this new
container. This way, it is not possible to peek into the private key using the <code>docker history</code> command.</p>
<p>By the way, I included two methods in the Dockerfile because <code>gcloud builds</code> does not accept a
<code>--build-arg</code> parameter similar to <code>docker build</code>. I’m sure there are other workarounds for passing
secrets to <code>gcloud</code> builds, but instead of digging for them, I found a solution that works for both
Docker and Google Cloud Run.</p>]]></content:encoded>
    </item>
    <item>
      <title>SSH Keys for Multiple Accounts on GitHub</title>
      <published>2018-11-18T16:18:58+00:00</published>
      <updated>2018-11-18T16:18:58+00:00</updated>
      <author>Emre Şahin</author>
      <pubDate>Sun, 18 Nov 2018 16:18:58 +0000</pubDate>
      <link>https://emresahin.net/ssh-keys-multiple-accounts-14371-8399/</link>
      <guid isPermaLink="true">https://emresahin.net/ssh-keys-multiple-accounts-14371-8399/</guid>
      <description>I have multiple GitHub accounts, and some of these are collaborators on others. I don’t like to enter my password every time I push, so I set up SSH keys for my accounts. However, GitHub (understandably) doesn’t accept the same key for more than one account. (Otherwise, how would it know which ac...</description>
      <category>DevOps</category>
      <category>Tutorial</category>
      <category>SSH</category>
      <category>GitHub</category>
      <category>Git</category>
      <category>Config</category>
      <content:encoded><![CDATA[<p>I have multiple GitHub accounts, and some of these are collaborators on others. I
don’t like to enter my password every time I push, so I set up SSH keys for my
accounts. However, GitHub (understandably) doesn’t accept the same key for more than one
account. (Otherwise, how would it know which account is being used?)</p>
<p>Fortunately, there is a way to use the <code>~/.ssh/config</code> file to specify different keys for different
target URLs.</p>
<pre><code class="language-config"># Personal account - the default config
Host github.com
   HostName github.com
   User git
   IdentityFile ~/.ssh/id_rsa

# Work Account
Host work.github.com
   HostName github.com
   User git
   IdentityFile ~/.ssh/id_rsa_work
</code></pre>
<p>Now you can create another SSH key in <code>~/.ssh/id_rsa_work</code> and add it to your
work account. When you configure a repository, you need to specify
<code>git@work.github.com:user/repo.git</code> as the repository address rather than
<code>git@github.com:user/repo.git</code>.</p>]]></content:encoded>
    </item>
  </channel>
</rss>
