0

I'm trying to do a simple script to automate my git workflow, and I thought I'd use echo to fill my credentials needed for git pull to work. However, this is not working. Is git pull not reading from stdin or am I doing something wrong? I used echo "username" | git pull, but after hitting enter and typing in my password I got a 403.

Jordan Running
  • 102,619
  • 17
  • 182
  • 182
Dunno
  • 3,632
  • 3
  • 28
  • 43
  • 3
    Consider setting up a passwordless setup... `git pull` is something you'll probably be running often enough to not want to constantly type a password. – user229044 Jul 03 '14 at 16:46
  • Depending on what auth mechanism you are using here git itself may be able to store the username (and possibly even password though I *strongly* recommend not doing that in general) for you. What auth are you using? – Etan Reisner Jul 03 '14 at 16:48
  • 1
    If you're using Git over HTTP/HTTPS (and so the usual SSH key route won't work for you), git has a useful credential helpers feature that will do this for you. Here's a great answer that shows how to set it up: http://stackoverflow.com/a/5343146/179125 – Jordan Running Jul 03 '14 at 16:48
  • Passwords are generally read direct from the terminal, not from stdin, so they can't be read from a pipeline. This is a security feature, not a bug -- running `echo password | foo` exposes `password` to anything in your system that can read the process table, which includes processes run by untrusted users like `nobody`. – Charles Duffy Feb 06 '15 at 22:02
  • ...so -- the Right Way to automate authentication with `git` is to load your SSH private key into an agent, and let it use that agent to authenticate. On many operating systems (MacOS X, or anything based on GNOME or KDE), there's support for unlocking that private key as part of your keychain -- potentially even automatically when you log in. Much safer, much more secure, no plaintext passwords stored anywhere on disk. [I may be a little biased, having written patches adding SSH agent support to several Java git clients, including that used by IntelliJ]. – Charles Duffy Feb 06 '15 at 22:05

0 Answers0