1

This is on Ubuntu, I have a user startup shell script that runs every time the instance boots (EC2 via --user-data-file argument). I want to have the instance do a git pull from a specific branch every time it boots. The problem is when I do a git pull, there is a SSH key passphrase prompt and I am not sure what the best way is to automatically enter the password in a shell script.

pixelfreak
  • 17,714
  • 12
  • 90
  • 109

2 Answers2

1

You should generate your public ssh key and ask the administrator of that branch to store the key in his authorized_keys file.

This is what you should do: Generating Your SSH Public Key

This is what the administrator should do: How to Use RSA Key for SSH Authentication

Yang
  • 7,712
  • 9
  • 48
  • 65
  • Yang, I am pulling from beanstalk. I don't think they let you add your own key to autorhized_keys – pixelfreak May 25 '12 at 00:26
  • Does ssh-agent help? See [this post](http://stackoverflow.com/questions/6265595/how-can-i-peform-a-git-pull-without-re-entering-my-ssh-password) – Yang May 25 '12 at 00:40
  • I saw that post, I'm not sure if that'll work coz in the script I'll need to start ssh-agent and run ssh-add, which will prompt for passphrase and we are back to square one :) – pixelfreak May 25 '12 at 00:42
1

Try Expect http://en.wikipedia.org/wiki/Expect it will allow you to provide password to interactive ssh session

BlacKow
  • 281
  • 2
  • 12
  • Thanks, this might work. Although I'll have to put the passphrase in the plain text, so I might as well just remove the passphrase from the ssh key. I also found some more secure alternatives, but they seem more involved. Anyway, I'll accept this answer in the meantime. Thanks again! – pixelfreak May 25 '12 at 18:13