We have a scenario when we need to generate ssh key with ssh-keygen on a windows machine and copy it to linux instance:
echo -e 'y\n' | ssh-keygen -t rsa -f /tmp/temp -N '' >/dev/null 2>&1
aws --profile dev --region us-east-1 ec2-instance-connect send-ssh-public-key \
--instance-id i-x123456 \
--availability-zone us-east-1a \
--instance-os-user ec2-user \
--profile dev \
--region us-east-1 \
--ssh-public-key file:///tmp/temp.pub
The problem the template of the pem created on windows doesn't match the linux template so when trying to use it for ssh (with aws session manager):
ssh -i /tmp/temp \
-Nf -M \
-L 3306:test-rds.xxxxxxxxxxx.us-east-1.rds.amazonaws.com:3306 \
-o "UserKnownHostsFile=/dev/null" \
-o "StrictHostKeyChecking=no" \
-o ProxyCommand="aws ssm start-session --target %h --document AWS-StartSSHSession --parameters portNumber=%p --profile dev --region us-east-1" \
ec2-user@i-x123456
it fails with: command-line: line 0: Bad configuration option: \342\200\234userknownhostsfile
Any way to generate pem on windows and copy it to a linux machine? Tnx!