在ec2 ubuntu实例上自动化Git拉取过程 [英] Automating Git pull process on a ec2 ubuntu instances
问题描述
我正在运行几个ubuntu ec2实例,我想运行一个自动化脚本,该脚本将在从AMI启动新实例时从Github中提取代码。事情是目前我正在 ssh
到服务器并运行命令 git pull origin master
,它将要求密码密钥。
I am running a couple of ubuntu ec2 instances, I want to run an automation script which will pull the code from Github whenever a new instance is booted from the AMI. The thing is presently I am ssh
ing to the server and run the command git pull origin master
and it will ask for password key.
如何自动执行此过程?因此,从AMI启动新实例后,该脚本应:
How do I automate this process? So after booting the new instance from a AMI this script should:
- 运行
- 拉出代码以及子模块
- 创建几个文件并进行配置
请帮助我实现
谢谢
推荐答案
这可能需要一些时间,
This will probably take some time and configuring, but this might set you on the right path.
首先,设置您的ssh密钥,以便您可以自动从存储库中提取密码,而无需输入密码。此处概述: https://help.github.com/articles/generating-ssh-keys
First, setup your ssh keys, so that you can automatically pull from a repo, without a password. Outlined here: https://help.github.com/articles/generating-ssh-keys
接下来,创建一个启动脚本以从Github发出 pull命令。此处: https://help.ubuntu.com/community/UbuntuBootupHowto
Next, create a startup script to issue the 'pull' command from Github. Here: https://help.ubuntu.com/community/UbuntuBootupHowto
然后保存您的AMI,当您启动新的EC2 AMI时,脚本应该运行,并提取您的Github更改。
Then save your AMI, When you start a new EC2 AMI, the script should run, pulling in your Github changes.
也可以请注意,请确保gits远程路径使用的是SSH,如果它是HTTPS,则始终会要求输入密码。
Also to note, make sure gits remote path is using SSH, if it is HTTPS, it will ALWAYS ask for a password.
这篇关于在ec2 ubuntu实例上自动化Git拉取过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!