<p>I have an <em>alpine</em> Docker image running in Kubernetes, in which I try to push to Git using a Deploy Key (with passphrase).</p>
<p>Now my command looks like:</p>
<pre class="lang-docker prettyprint-override"><code>CMD [&quot;/bin/sh&quot;, &quot;-c&quot;, &quot;GIT_SSH_COMMAND=\&quot;sshpass -p mygreatpassphrase ssh -vvv\&quot; git -C /workspace push --mirror git@github.com:foo/bar.git&quot;]
</code></pre>
<p>The result then is:</p>
<pre class="lang-shell prettyprint-override"><code>&lt;snip&gt;
debug3: send packet: type 21
debug2: set_newkeys: mode 1
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug3: receive packet: type 21
debug1: SSH2_MSG_NEWKEYS received
debug2: set_newkeys: mode 0
debug1: rekey after 134217728 blocks
debug1: Will attempt key: /.ssh/id_rsa 
debug1: Will attempt key: /.ssh/id_dsa 
debug1: Will attempt key: /.ssh/id_ecdsa 
debug1: Will attempt key: /.ssh/id_ed25519 
debug1: Will attempt key: /.ssh/id_xmss 
debug2: pubkey_prepare: done
debug3: send packet: type 5
debug3: receive packet: type 7
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=&lt;ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-rsa,rsa-sha2-512,rsa-sha2-256,ssh-dss&gt;
debug3: receive packet: type 6
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug3: send packet: type 50
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey
debug3: start over, passed a different list publickey
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /.ssh/id_rsa
</code></pre>
<p>It hangs on this line indefinitely. Sadly it seems there is no more verbose output for <code>ssh</code>. I am not sure whether the problem is with <code>sshpass</code> inside the container or where the actual problem arises.</p>
<p>Building in Docker hangs, too:</p>
<pre class="lang-docker prettyprint-override"><code>FROM alpine/git

RUN apk add --no-cache sshpass

RUN sshpass -p foo /bin/sh -c 'read X &lt; /dev/tty'
</code></pre>
<p><code>sshpass</code> has the following files open:</p>
<pre class="lang-shell prettyprint-override"><code>lr-x------    1 tempuser root            64 Jul 31 10:43 0 -&gt; pipe:[380942247]
l-wx------    1 tempuser root            64 Jul 31 10:43 1 -&gt; pipe:[380942248]
l-wx------    1 tempuser root            64 Jul 31 10:43 2 -&gt; pipe:[380944011]
lrwx------    1 tempuser root            64 Jul 31 10:43 3 -&gt; /dev/pts/ptmx
lrwx------    1 tempuser root            64 Jul 31 10:43 4 -&gt; /dev/pts/0
</code></pre>
<p><code>ssh</code> in contrast:</p>
<pre class="lang-shell prettyprint-override"><code>lr-x------    1 tempuser root            64 Jul 31 09:23 0 -&gt; pipe:[380942247]
l-wx------    1 tempuser root            64 Jul 31 09:23 1 -&gt; pipe:[380942248]
l-wx------    1 tempuser root            64 Jul 31 09:23 2 -&gt; pipe:[380944011]
lrwx------    1 tempuser root            64 Jul 31 09:23 3 -&gt; socket:[380944638]
lrwx------    1 tempuser root            64 Jul 31 10:43 4 -&gt; /dev/tty
</code></pre>

<p>For Keys with a Passphrase, the SSH prompt is different.
So I had to change the prompt using <code>-P assphrase</code>:</p>
<pre class="lang-docker prettyprint-override"><code>CMD [&quot;/bin/sh&quot;, &quot;-c&quot;, &quot;GIT_SSH_COMMAND=\&quot;sshpass -p mygreatpassphrase -P assphrase ssh -vvv\&quot; git -C /workspace push --mirror git@github.com:foo/bar.git&quot;]
</code></pre>
