简体   繁体   English

如何在EC2实例中克隆私有Git存储库

[英]How to clone private Git repository in EC2 instance

I have a lambda function which starts an EC2 instance. 我有一个启动EC2实例的lambda函数。 I specify in the boto3 call the user_data some bash script which install dependencies and start services. 我在boto3user_data调用了一些bash脚本,用于安装依赖项并启动服务。

I would like to clone a private Bitbucket repository at that time, so my question is... 我当时想克隆一个私有的Bitbucket存储库,所以我的问题是...

What is the best practice in this case? 在这种情况下,最佳做法是什么?

I am thinking about download some ssh keys from S3 and configure everything with the user_data script but I think is not a good practice. 我正在考虑从S3下载一些ssh密钥,并使用user_data脚本配置所有内容,但我认为这不是一个好习惯。

Suggestions? 有什么建议吗?

Thanks in advance! 提前致谢!

Finally I managed the SSH key inside a S3 bucket and provision that key with the following code in the user_data script: 最后,我在S3存储桶中管理了SSH密钥,并在user_data脚本中使用以下代码设置了该密钥:

aws s3 cp s3://<bucket_name>/resources/id_rsa id_rsa --region <your_region>
chmod 600 id_rsa
mkdir -p /root/.ssh
ssh-keyscan -t rsa <your_domain> > /root/.ssh/known_hosts
mv id_rsa /root/.ssh/id_rsa

Of course that bucket is protected in order to avoid an accidental exposure of the key. 当然,该桶是受保护的,以避免意外暴露钥匙。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 EC2:如何克隆Git存储库 - EC2: How to Clone Git Repository Git克隆到Amazon AWS EC2实例的私有存储库 - Git clone private repo to Amazon AWS EC2 instance 在AWS EC2实例上的dockerfile中将git clone作为主机和私有git存储库运行时,主机验证失败错误 - Host verification failed error when running git clone inside dockerfile on AWS EC2 instance as host and a private git repository 有没有办法在使用 Terraform 创建实例时在 ec2 实例中克隆私有 git repo? - Is there a way to clone a private git repo inside ec2 instance when creating the instance using Terraform? Git 克隆 EC2 实例权限错误 - Git Clone EC2 Instance Permissions Error 如何授予对Amazon EC2实例中托管的git存储库的访问权限? - How to grant access to a git repository hosted in an amazon EC2 instance? 使用 ssh 从 AWS EC2 中的存储库进行 Git 克隆? - Git clone using ssh from a repository in AWS EC2? 在EC2实例上进行“ git clone…”需要哪些安全组设置? - What security group settings are needed to `git clone …` on an EC2 instance? 如何在AWS EC2实例上克隆公司内部的Git(Stash)存储库? - How can I clone a Git (Stash) repo which is in-premise in my company, on AWS EC2 instance? 如何使用私钥克隆GIT存储库 - How to clone GIT repository with private key
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM