2

I'm trying to push my password over to my git push to make a quick way to add, commit and push, but am unable to get the bash prompt to push and enter my password. Does someone know how to do this? I'm sure it mush be simple....

#!/bin/bash

PWD='password'
read MSG

git add .
git commit -m '"$MSG"'

echo "$PWD" | git push |
ehime
  • 8,025
  • 14
  • 51
  • 110

2 Answers2

2

If you're using git over ssh, you are not able to pipe in a password because the password is read directly from the tty device, and not stdin (in part to discourage doing things like that! ;)). If you really want to automate the password entry, consider using expect which can control the tty. expect uses TCL, but there are also modules at least for perl and python if you're more inclined with one of those.

IMO, the better solution would be to set up key based auth. it's both easier and more secure than what you're attempting. http://www.debian-administration.org/articles/530 has some info on how to set it up.

FatalError
  • 52,695
  • 14
  • 99
  • 116
  • Thanks, the reason that I want to do this is to automate my entire process of pushing pulling adding and such. I'll look into expect @sehe and ssh keys, thanks guys – ehime Feb 03 '12 at 23:45
1

You can't do this.

Instead, git push over ssh (which you probably are using already) and configure ssh to use public key authentication. ssh-agent can help supply the passphrase if you opt to protect your private key with one.

See the github tutorials for some guidance: http://help.github.com/ssh-key-passphrases/

sehe
  • 374,641
  • 47
  • 450
  • 633