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: debug1: Server 
accepts key: pkalg ssh-rsa blen 279
Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1: 
Authentication succeeded (publickey).
Notice: /Stage[main]/Main/Exec[ssh know github]/returns: Authenticated to 
github.com ([192.30.252.129]:22).
Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1: channel 0: 
new [client-session]
Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1: Requesting 
no-more-sessi...@openssh.com
Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1: Entering 
interactive session.
Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1: Remote: 
Forced command.
Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1: Remote: 
Port forwarding disabled.
Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1: Remote: 
X11 forwarding disabled.
Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1: Remote: 
Agent forwarding disabled.
Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1: Remote: 
Pty allocation disabled.
Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1: Remote: 
Forced command.
Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1: Remote: 
Port forwarding disabled.
Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1: Remote: 
X11 forwarding disabled.
Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1: Remote: 
Agent forwarding disabled.
Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1: Remote: 
Pty allocation disabled.
Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1: Sending 
environment.
Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1: Sending 
env LC_ALL = en_US
Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1: 
client_input_channel_req: channel 0 rtype exit-status reply 0
Notice: /Stage[main]/Main/Exec[ssh know github]/returns: Hi apennebaker! 
You've successfully authenticated, but GitHub does not provide shell access.
Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1: channel 0: 
free: client-session, nchannels 1
Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1: fd 0 
clearing O_NONBLOCK
Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1: fd 1 
clearing O_NONBLOCK
Notice: /Stage[main]/Main/Exec[ssh know github]/returns: Transferred: sent 
2680, received 3128 bytes, in 0.0 seconds
Notice: /Stage[main]/Main/Exec[ssh know github]/returns: Bytes per second: 
sent 55164.4, received 64385.9
Notice: /Stage[main]/Main/Exec[ssh know github]/returns: debug1: Exit 
status 1
Notice: Finished catalog run in 5.64 seconds

As a workaround, I'm forcing the overall command to succeed:

`ssh -Tv g...@github.com -o StrictHostKeyChecking=no; echo Success`

But in the long run, I'd prefer not to do this, in case the git command 
actually does fail (e.g., network outage). Is there a more idiomatic way to 
correct the exit status? Is there an inline way in bash to consider "0" or 
"1" successful, but not other values?

I apologize if this isn't quite the right forum for this question. If you'd 
like, I can repost this to elsewhere.

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to