Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Login without .pem file #11

Open
sholtomaud opened this issue Sep 4, 2022 · 0 comments
Open

Login without .pem file #11

sholtomaud opened this issue Sep 4, 2022 · 0 comments

Comments

@sholtomaud
Copy link

Hi Brian, a user on the CDK Slack channel gave the following methods which avoid the .pem file problem:

Host myhost
   ProxyCommand sh -c "aws ec2-instance-connect send-ssh-public-key \
      --instance-id  $(aws ec2 describe-instances --filter "Name=tag:Name,Values= HOSTNAME"  \
      --query "Reservations[].Instances[?State.Name =='running'].InstanceId[]"  \
      --output text --profile profilename) \
      --availability-zone ap-southeast-2a \
      --instance-os-user ec2-user \
      --ssh-public-key file:///Users/someuser/.ssh/somekey.pub --profile profilename > /dev/null; \
      aws ssm start-session --profile profilename \ 
      --target $(aws ec2 describe-instances --filter "Name=tag:Name,Values= HOSTNAME" \
      --query "Reservations[].Instances[?State.Name =='running'].InstanceId[]" 
      --output text --profile profilename) --profile profilename  \
      --document-name AWS-StartSSHSession --parameters 'portNumber=%p'"
   User ec2-user
   ForwardAgent yes
   UserKnownHostsFile /dev/null
   StrictHostKeyChecking no
Host myhost
   ProxyCommand C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe "aws ec2-instance-connect send-ssh-public-key \
   --instance-id  $(aws ec2 describe-instances --filter "Name=tag:Name,Values= HOSTNAME"  \
   --query "Reservations[].Instances[?State.Name =='running'].InstanceId[]"  \
   --output text --profile profilename) \
   --availability-zone ap-southeast-2a \
   --instance-os-user ec2-user \
   --ssh-public-key file:///Users/someuser/.ssh/somekey.pub --profile profilename > /dev/null; \
   aws ssm start-session --profile profilename \ 
   --target $(aws ec2 describe-instances --filter "Name=tag:Name,Values= HOSTNAME" \
   --query "Reservations[].Instances[?State.Name =='running'].InstanceId[]" 
   --output text --profile profilename) --profile profilename  \
   --document-name AWS-StartSSHSession --parameters 'portNumber=%p'"
   User ec2-user
   ForwardAgent yes
   UserKnownHostsFile /dev/null
   StrictHostKeyChecking no
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant