masasam / emacs-easy-hugo

Emacs major mode for managing hugo
https://gohugo.io/tools/editors/#emacs
GNU General Public License v3.0
362 stars 26 forks source link

How to pass password to deploy.sh? #27

Closed btimofeev closed 7 years ago

btimofeev commented 7 years ago

Hello.

I have a blog on the github pages and I use this script for deployment:

#!/bin/bash

echo -e "\033[0;32mDeploying updates to GitHub...\033[0m"
hugo 

cd public
git add -A

msg="rebuilding site `LANG=C date`"
if [ $# -eq 1 ]
  then msg="$1"
fi
git commit -m "$msg"

git push origin master

cd ..

In the script git push command prompts for a ssh password in the console, but easy-hugo not request a password and therefore no changes are made to the server.

Is it possible to somehow request a password inside easy-hugo when deploying?

masasam commented 7 years ago

Hi @btimofeev . Thank you for report.

Since I connect to GitHub with SSH (see https://help.github.com/articles/connecting-to-github-with-ssh/) and I use keychain (see http://www.funtoo.org/Keychain), No password is required.

If you pass passwords with shellscript you'd better use expect. See https://stackoverflow.com/questions/4780893/use-expect-in-bash-script-to-provide-password-to-ssh-command.

btimofeev commented 7 years ago

Thank you for response. Keychain works, but maybe this will not work if you restart the computer and deploy the site without opening the terminal before that.

I found some information on how to work with passwords at the bottom of this page, maybe this will help for future releases.

masasam commented 7 years ago

Hi @btimofeev . Thank you for response. When I actually run it now, this work if I restart the computer and deploy the site without opening the terminal before that.

cescoferraro commented 7 years ago

@btimofeev https://stackoverflow.com/questions/11403407/git-asks-for-username-every-time-i-push

$ git config credential.helper store
$ git push http://example.com/repo.git
Username: <type your username>
Password: <type your password>

Do this once then git wont ask for credential ever again on the machine you typed this

masasam commented 7 years ago

Hi @cescoferraro . I didn't know git credential caching. It seems like this can also be used for password escape. Thank you for your advice.