amazon-ec2 - Amazon EC2 中的 Git 到本地机器

标签 amazon-ec2 gitolite public-key git-clone

我按照以下步骤在亚马逊实例 EC2 中安装了 Git 和 Gitolite:

在本地创建公钥并将其发送到 EC2:

ssh-keygen -t rsa
cp ~/.ssh/id_rsa.pub /tmp/local.pub
rsync -avr /tmp/local.pub -e "ssh -i my-ec2-key.pem" root@xx.xx.xxx.xxx:/tmp/local.pub

然后安装 Git 和 gitolite :

sudo apt-get install git gitolite git-daemon-run

然后在EC2中为git用户创建了一个账号:

sudo adduser --system --shell /bin/bash --gecos 'git version control' --group --disabled-password --home /home/git git
su git
cd /home/git
echo "PATH=$HOME/bin:$PATH" > .bashrc
gl-setup /tmp/local.pub

当我尝试使用以下命令从本地计算机的 EC2 克隆存储库时,它返回了一个错误:

rui@rui:~/.ssh$ git clone git@ec2-xx-xxx-xx-xx.compute-1.amazonaws.com:testing.git

Cloning into 'testing'...
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

我尝试了不同的方法,但最终错误是一样的。

最佳答案

您可以查看一些内容:

  • gitolite-admin.git 存储库中的 gitolite.conf。确保内容是这样的。

    repo    gitolite-admin
            RW+     =   rui
    
    repo    testing
            RW+     =   @all
    
  • 在 gitolite-admin.git 存储库的 gitolite-admin/keydir 目录中检查您的公钥文件是否存在。此外,它与您用于连接的文件的私钥相匹配。

我自己设置了 gitolite,对我来说效果很好。

关于amazon-ec2 - Amazon EC2 中的 Git 到本地机器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21141843/

相关文章:

gitolite(版本 3),更新管理 key

javascript - 从AWS SDK描述地址检索IP

amazon-web-services - docker 问题 devmapper : Unknown device

Apache DocumentRoot 的 Gitolite 本地工作副本

子模块的 Gitolite 镜像

public-key - 为什么公钥算法很慢?

api - 无效的公钥 - revolut 沙箱

java - 从 keystore 中的文件中读取公钥

bash - user_data 在 terraform 应用程序之后不运行

amazon-ec2 - 如何创建与vpc相关的模板ec2