2

I am able to connect and interact with a remote git server via terminal but am unable to do so with PHP. I am trying to execute the following command:

GIT_SSH_COMMAND="ssh -vvv -i ~/.ssh/id_rsa -F /dev/null" \
/usr/local/bin/git push -u origin master

If I do the same command in the terminal it works no problem. I have searched the internet for answers and haven't been able to find a solution that works.

Now keep in mind the repo does not exist yet. I am trying to create it via this command. I did successfully create another repo minutes before with this exact command. Any idea what I am missing?

Here is the debug output.

array:49 [▼
  0 => "OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011"
  1 => "debug1: Reading configuration data /dev/null"
  2 => "debug1: Connecting to git.modernizedmedia.com [208.53.61.173] port 22."
  3 => "debug1: Connection established."
  4 => "debug1: identity file /Users/greenorange/.ssh/id_rsa type 1"
  5 => "debug1: identity file /Users/greenorange/.ssh/id_rsa-cert type -1"
  6 => "debug1: Enabling compatibility mode for protocol 2.0"
  7 => "debug1: Local version string SSH-2.0-OpenSSH_6.2"
  8 => "debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1"
  9 => "debug1: match: OpenSSH_6.6.1 pat OpenSSH*"
  10 => "debug1: SSH2_MSG_KEXINIT sent"
  11 => "debug1: SSH2_MSG_KEXINIT received"
  12 => "debug1: kex: server->client aes128-ctr [email protected] none"
  13 => "debug1: kex: client->server aes128-ctr [email protected] none"
  14 => "debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent"
  15 => "debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP"
  16 => "debug1: SSH2_MSG_KEX_DH_GEX_INIT sent"
  17 => "debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY"
  18 => "debug1: Server host key: RSA ae:63:f0:7f:aa:62:5d:ac:ef:98:d6:66:a9:9c:4d:ce"
  19 => "debug1: Host 'git.modernizedmedia.com' is known and matches the RSA host key."
  20 => "debug1: Found key in /Users/greenorange/.ssh/known_hosts:64"
  21 => "debug1: ssh_rsa_verify: signature correct"
  22 => "debug1: SSH2_MSG_NEWKEYS sent"
  23 => "debug1: expecting SSH2_MSG_NEWKEYS"
  24 => "debug1: SSH2_MSG_NEWKEYS received"
  25 => "debug1: SSH2_MSG_SERVICE_REQUEST sent"
  26 => "debug1: SSH2_MSG_SERVICE_ACCEPT received"
  27 => "debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password"
  28 => "debug1: Next authentication method: publickey"
  29 => "debug1: Offering RSA public key: /Users/greenorange/.ssh/id_rsa"
  30 => "debug1: Server accepts key: pkalg ssh-rsa blen 535"
  31 => "debug1: key_parse_private_pem: PEM_read_PrivateKey failed"
  32 => "debug1: read PEM private key done: type <unknown>"
  33 => "debug1: read_passphrase: can't open /dev/tty: Device not configured"
  34 => "debug1: Next authentication method: password"
  35 => "debug1: read_passphrase: can't open /dev/tty: Device not configured"
  36 => "debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password"
  37 => "Permission denied, please try again."
  38 => "debug1: read_passphrase: can't open /dev/tty: Device not configured"
  39 => "debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password"
  40 => "Permission denied, please try again."
  41 => "debug1: read_passphrase: can't open /dev/tty: Device not configured"
  42 => "debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password"
  43 => "debug1: No more authentication methods to try."
  44 => "Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password)."
  45 => "fatal: Could not read from remote repository."
  46 => ""
  47 => "Please make sure you have the correct access rights"
  48 => "and the repository exists."
]
7
  • 1
    read_passphrase: can't open /dev/tty: Device not configured" <- there's your problem. Also, is /Users/greenorange/.ssh/id_rsa the private key you expect to load? Commented Aug 31, 2018 at 3:47
  • Yes, that is the correct private key. How can I remedy that error and why am I not seeing it when running the command in my terminal? Commented Aug 31, 2018 at 3:52
  • You probably have an ssh-agent running. See help.github.com/articles/working-with-ssh-key-passphrases. One solution for machine-account private keys is to not have a passphrase Commented Aug 31, 2018 at 3:53
  • Okay, That makes sense. Any suggestions on how I can remedy the problem? Would I just need to use a new rsa key that doesn't have a passphrase attached to it? Commented Aug 31, 2018 at 3:57
  • That's definitely one solution Commented Aug 31, 2018 at 3:58

1 Answer 1

3

The problem is identified here

read_passphrase: can't open /dev/tty: Device not configured

Your private key requires a passphrase which cannot be entered because there is no terminal. You may not be seeing this when you run the command in your terminal due to your ssh-agent.

See https://help.github.com/articles/working-with-ssh-key-passphrases/

One solution is to create a new key pair for the remote service without a passphrase.

The security implications of this are whatever remote services that have the new public key are now only as secure as the copy of the private key (ie, your local machine account). Assess that risk however you like.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.