Elastic beanstalk access private git repo
I am trying to currently add an ssh key to my elastic beanstalk instances using .ebextensions commands.
The keys I have stored are in my application code and I try to copy them to the root .ssh folder so I can access them when doing a git+ssh clone later
here is an example of the config file in my .ebextensions folder
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"
the problem is that I get is an error when attempting to clone the repo
Host key verification failed.
I have tried many ways of try to add the host to the known_hosts file but none have worked!
The command that is doing the clone is npm install as the repo points to a node module
I added this to my ebextensions. This was what I used to connecting to code commit. I needed to specify the user and ignore host key checking. Hope this helps anybody stopping by...
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"