指示git拉入shell脚本的密码,无ssh? [英] indicate a password for git pull in shell script, without ssh?

查看:190
本文介绍了指示git拉入shell脚本的密码,无ssh?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个shell脚本来执行项目释放,使用 Git ,在shell脚本中我首先 cd 到Git工作副本,然后执行 git pull origin master

但它会提示我输入密码: git @ localhost的密码:,这很烦人,我想知道是否可以在脚本中指明 git pull 的密码,如下所示:

git pull origin master --password abcd123

任何想法?

解决方案通常:不要将密码放入脚本中,尤其不要将它们提供给命令参数,因为这意味着它们通过 ps 命令发布到任何人在同一台计算机上。



这里的解决方案是使用ssh并运行ssh代理。代理加载您的私钥,并在它尝试通过SSH连接到远程端时将其提供给shell脚本。这样,你只需要把你的通行短语给代理。



这篇博文应该给你更多的细节:使用OpenSSH进行无密码登录



如果您使用Windows, putty 具有相同的功能。


I wrote a shell script to do project releasing with Git, in the shell script I first cd to the Git working copy and then do git pull origin master.
But it prompts me for password: git@localhost's password:, this's annoying, and I'm wondering if I can indicate the password for git pull in the script, like this:
git pull origin master --password abcd123
Any idea?

解决方案

Generally: Don't put passwords into scripts and especially don't supply them with command arguments because that means they are published via the ps command to anyone on the same computer.

The solution here is to use ssh and run an ssh agent. The agent loads your private key and supplies that to the shell script when it tries to connect to the remote side via SSH. That way, you only need to give your pass phrase to the agent.

This blog post should give you more details: Password-less logins with OpenSSH

If you're using Windows, putty comes with the same functionality.

这篇关于指示git拉入shell脚本的密码,无ssh?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆