MrD
MrD

Reputation: 545

Using git without X11 forwarding

When I try to use git on a remote machine (via ssh), it complains of not being able to connect to my display. Since I'm using this ssh connection within a screen environment from different machines, I cannot use X11 forwarding. However, I do not want any graphical interface for typing in my password.

Command:

$ git pull

connect localhost port 6010: Connection refused

(gnome-ssh-askpass:7316): Gtk-WARNING **: cannot open display: localhost:36.0

Version:

$ git --version

git version 1.7.1

How can I get around the need for a graphical connection here?

Upvotes: 3

Views: 1751

Answers (1)

kostix
kostix

Reputation: 55553

Please read the gitcredentials(7) manual page (you can run git help credentials to read it locally).

It explains how Git manages the problem of obtaining your credentials.

Namely, the usage of the GIT_ASKPASS environment variable might be of interest to you.

Alternatively, you could allow your SSH client to forward connection to your local agent (the thing which keeps your keys) so that Git running in the remote session could use the same identities. Of coure, use this only if applicable (that is, the identities are the same). In this case, SSH won't supposedly even try to ask for the password since it will be serviced by the agent. Read the ssh_config(5) manual page and look for the ForwardAgent configuration option.

To reiterate, the root of your problem appears to be in that SSH needs to ask you for your credentials, and you have to make sure it doesn't. Hence maybe the solution is as simple as running ssh-agent in the remote session and ssh-add-ing the necessary identities to it before running Git or just making sure environment variables and Git configuration settings related to obtaining credentials for SSH have meaningful values.

Upvotes: 1

Related Questions