I'm a bit confused. I'm trying to use a github action to SSH into my ec2 instance and do a deploy. I have the key (from ec2 console) saved as a secret in github as such:
- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.COBOTSSH }}
name: id_rsa
known_hosts: ${{ secrets.KNOWN_HOSTS }}
- name: ssh
run: ssh ${{ secrets.USERNAME }}@${{ secrets.KNOWN_HOSTS }}
Unfortunately I get:
Host key verification failed.
I've tried multiple SSH github action solutions, so I assume this is user error (shimataro is the gold standard). So i'm gonna be really specific as to what I did:
- Went to keypairs
- Created a new keypair and downloaded the pem file
- Copied the entire text of the pem file into the secret COBOTSSH
- Copied the DNS name of the EC2 instance into KNOWN_HOSTS (contrary to the variable name, it's just a single DNS entry)
- Logged into the box using SSH on my putty terminal, and created a user called X and then put X into the USERNAME secret.
I assume this is erroring because it requires a password by default? But the error does not have any verbosity. How do I use the key from the EC2 console and still run commands like
ssh-copy-id? A ny line by line example of how to do this would be super appreciated - I am a linux noob.
-o StrictHostKeyChecking=noto the command line, i.e.run: ssh -o StrictHostKeyChecking=no ${{ secrets.USERNAME }}@${{ secrets.KNOWN_HOSTS }}secrets.COBOTSSHwill be used in the latter (key-based authentication) but the error message is telling you the process fails on host key verification, before it would be trying COBOTSSH key.