use*_*676 7 ssh git node.js elastic-beanstalk
我目前正在尝试使用 .ebextensions 命令向我的弹性 beanstalk 实例添加一个 ssh 密钥。
我存储的密钥在我的应用程序代码中,我尝试将它们复制到根 .ssh 文件夹,以便稍后在执行 git+ssh 克隆时访问它们
这是我的 .ebextensions 文件夹中的配置文件示例
packages:
yum:
git: []
container_commands:
01-move-ssh-keys:
command: "cp .ssh/* ~root/.ssh/; chmod 400 ~root/.ssh/tca_read_rsa; chmod 400 ~root/.ssh/tca_read_rsa.pub; chmod 644 ~root/.ssh/known_hosts;"
02-add-ssh-keys:
command: "ssh-add ~root/.ssh/tca_read_rsa"
Run Code Online (Sandbox Code Playgroud)
问题是我在尝试克隆 repo 时遇到错误
Host key verification failed.
Run Code Online (Sandbox Code Playgroud)
我尝试了多种尝试将主机添加到 known_hosts 文件的方法,但都没有奏效!
执行克隆的命令是 npm install 因为 repo 指向节点模块
小智 1
我将其添加到我的 ebextensions 中。这就是我用来连接代码提交的方式。我需要指定用户并忽略主机密钥检查。希望这对任何路过的人都有帮助...
commands:
add_ssh_config:
command: printf "Host git-codecommit.*.amazonaws.com\r\n StrictHostKeyChecking no\r\n User <name-of-user>\r\n IdentityFile ~/.ssh/<name-of-key>.pem" > /home/ec2-user/.ssh/config"
Run Code Online (Sandbox Code Playgroud)