Git, ssh, and dropbear (solved)

I cannot tell you how long I spent trying to get dropbear & git to work on my BBB.

I finally got it working and wanted to post it somewhere in case there are others out there struggling like I was.

I have been using the instructions from this link here:
using-git-with-the-dropbear-ssh-client

It got me pretty far, I created my key, copied the public key up to github and had the illusion of getting somewhere.

I couldn’t get the test ssh to ever work:

root@beaglebone:~/projects/Beagle_GPIO# ssh -i ~/.ssh/id_rsa -vT git@github.com
OpenSSH_6.0p1, OpenSSL 1.0.0j 10 May 2012
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 20: Applying options for *
debug1: Connecting to github.com [204.232.175.90] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /home/root/.ssh/id_rsa type -1
debug1: identity file /home/root/.ssh/id_rsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.5p1 Debian-6+squeeze1+github12
debug1: match: OpenSSH_5.5p1 Debian-6+squeeze1+github12 pat OpenSSH_5*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.0
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA xx:xx:xx:xx:xx:xx:xx
debug1: Host ‘github.com’ is known and matches the RSA host key.
debug1: Found key in /home/root/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /home/root/.ssh/id_rsa
debug1: key_parse_private_pem: PEM_read_PrivateKey failed
debug1: read PEM private key done: type
Enter passphrase for key ‘/home/root/.ssh/id_rsa’:
debug1: No more authentication methods to try.
Permission denied (publickey).

No amount of google fu could get me past the “PEM_read_PrivateKey failed” message. I tried a number of other ssh options and all failed.

root@beaglebone:~/.ssh# ssh -o BatchMode=yes -o PasswordAuthentication=no -i ~/.ssh/id_rsa -vt git@github.com
OpenSSH_6.0p1, OpenSSL 1.0.0j 10 May 2012
<>
debug1: key_parse_private_pem: PEM_read_PrivateKey failed
debug1: read PEM private key done: type
debug1: No more authentication methods to try.
Permission denied (publickey).

It turns out that using ‘ssh’ was the culprit for me the whole time. I stumbled upon this link here:
dropbear-rsa-key-problem

I decided to give the ‘dbclient’ command a whirl and what do yah know? It worked.

oot@beaglebone:~/projects/Beagle_GPIO# dbclient -y -i ~/.ssh/id_rsa git@github.com

Host ‘github.com’ key accepted unconditionally.
(fingerprint md5 xx:xx:xx:xx:xx:xx:xx)
Hi gsansoucie! You’ve successfully authenticated, but GitHub does not provide shell access.

So the trick is to not use ssh, use dbclient.

My modified gitssh.sh script is:

#!/bin/sh
dbclient -y -i ~/.ssh/id_rsa $*

And the important export:
GIT_SSH=/home/root/gitssh.sh

So now when I do a git operation, it completes:

root@beaglebone:~/projects/Beagle_GPIO# git pull

Host ‘github.com’ key accepted unconditionally.
(fingerprint md5 xx:xx:xx:xx:xx:xx:xx)
From github.com:gsansoucie/Beagle_GPIO

  • branch HEAD → FETCH_HEAD
    Already up-to-date.

Hopefully this helps someone else.

Thank you.

在 2013年6月29日星期六UTC+8上午9时46分51秒,Glen Sansoucie写道:

You made my day! It so easy :slight_smile: