I know it's been a while, but I have recently had similar problem and the
solution I settled on looks like this:
ssh -q g...@github.com 2>&1 | grep "successfully"
this is a simple check to see if user authed or not. will return 0 if yes,
1 in all other cases.
Hope that helps
On Tuesday, March 4, 2014 4:47:21 PM UTC, Andrew Pennebaker wrote:
>
> I want to git clone some private repos as part of a Vagrant installation.
> I can do this with help from ssh agent forwarding, Puppet, and
> puppet-vcsrepo. However, I have to write a Puppet exec step to accept
> GitHub's server key:
>
> `git -Tv g...@github.com -o StrictHostKeyChecking=no`
>
> A trace shows SSH authentication completing successfully, but this command
> returns an exit status code of 1 (failure). This oddity confuses my Puppet
> script, leading it to believe that the command failed, preventing the next
> steps in my Puppet script from executing.
>
> Trace:
>
> $ vagrant provision
> ...
> Notice: /Stage[main]/Main/Exec[ssh know gitlab]/returns: executed
> successfully
> Notice: /Stage[main]/Main/Exec[ssh know github]/returns: OpenSSH_5.9p1
> Debian-5ubuntu1, OpenSSL 1.0.1 14 Mar 2012
> Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1: Reading
> configuration data /etc/ssh/ssh_config
> Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1:
> /etc/ssh/ssh_config line 19: Applying options for *
> Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1:
> Connecting to github.com [192.30.252.129] port 22.
> Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1:
> Connection established.
> Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1: identity
> file /home/vagrant/.ssh/id_rsa type -1
> Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1: identity
> file /home/vagrant/.ssh/id_rsa-cert type -1
> Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1: identity
> file /home/vagrant/.ssh/id_dsa type -1
> Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1: identity
> file /home/vagrant/.ssh/id_dsa-cert type -1
> Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1: identity
> file /home/vagrant/.ssh/id_ecdsa type -1
> Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1: identity
> file /home/vagrant/.ssh/id_ecdsa-cert type -1
> Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1: Remote
> protocol version 2.0, remote software version OpenSSH_6.2p2
> Ubuntu-6ubuntu0.1+github2
> Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1: match:
> OpenSSH_6.2p2 Ubuntu-6ubuntu0.1+github2 pat OpenSSH*
> Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1: Enabling
> compatibility mode for protocol 2.0
> Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1: Local
> version string SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1
> Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1:
> SSH2_MSG_KEXINIT sent
> Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1:
> SSH2_MSG_KEXINIT received
> Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1: kex:
> server->client aes128-ctr hmac-md5 none
> Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1: kex:
> client->server aes128-ctr hmac-md5 none
> Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1: sending
> SSH2_MSG_KEX_ECDH_INIT
> Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1: expecting
> SSH2_MSG_KEX_ECDH_REPLY
> Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1: Server
> host key: RSA 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48
> Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1: Host '
> github.com' is known and matches the RSA host key.
> Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1: Found key
> in /home/vagrant/.ssh/known_hosts:3
> Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1:
> ssh_rsa_verify: signature correct
> Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1:
> SSH2_MSG_NEWKEYS sent
> Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1: expecting
> SSH2_MSG_NEWKEYS
> Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1:
> SSH2_MSG_NEWKEYS received
> Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1: Roaming
> not allowed by server
> Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1:
> SSH2_MSG_SERVICE_REQUEST sent
> Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1:
> SSH2_MSG_SERVICE_ACCEPT received
> Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1:
> Authentications that can continue: publickey
> Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1: Next
> authentication method: publickey
> Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1: Offering
> RSA public key: /Users/apennebaker/.ssh/id_rsa
> Notice: /Stage[main]/Main/Exec[ssh know github]/returns: