- Newest
- Most votes
- Most comments
Hi
I tried but this doesn't output a correct format for EC2 key
ssh-keygen -e -f ~/.ssh/id_ed25519_sk.pub -m "RFC4716" > ~/.ssh/id_ed25519.pub
Output begins with ---- BEGIN SSH2 PUBLIC KEY ---- with is not the one expected
Hi,
Follow the guidance of section Use a third-party tool to generate a key pair, and then transfer the public key to Amazon EC2
in https://allcode.com/creating-a-new-aws-ec2-key-for-a-third-party-developer/ to achieve what you want.
Best,
Didier
this could be down to ECT supporting the ssh-ed25519
key type, but it doesn't directly support the sk-ssh-ed25519
key type, which is the format used for security key (Yubikey) SSH keys.
The sk-ssh-ed25519
key type is a specific format used for security keys that include a "security key" (sk) marker in the key type. This is to differentiate them from regular ssh-ed25519
keys that are not associated with a security key.
To import a Yubikey (or other security key) SSH public key to EC2, you'll need to convert the key format from sk-ssh-ed25519
to ssh-ed25519
. Here's how you can do that:
-
Obtain the public key from your Yubikey
- Connect your Yubikey to your computer.
- Use the
ssh-keygen
command to extract the public key:ssh-keygen -L -f ~/.ssh/id_ed25519_sk.pub
- This will display the public key in the
sk-ssh-ed25519
format.
-
Convert the key format
- You can use the
ssh-keygen
command to convert the key format fromsk-ssh-ed25519
tossh-ed25519
:ssh-keygen -e -f ~/.ssh/id_ed25519_sk.pub -m "RFC4716" > ~/.ssh/id_ed25519.pub
- This will create a new file
~/.ssh/id_ed25519.pub
containing the public key in thessh-ed25519
format.
- You can use the
-
Import the converted public key to EC2
- In the AWS Management Console, navigate to the EC2 service.
- Go to the "Key Pairs" section and click on "Import key pair".
- Give the key pair a name and paste the contents of the
~/.ssh/id_ed25519.pub
file into the "Public key contents" field. - Click "Import key pair" to add the key to your EC2 environment.
Now you should be able to use the imported ssh-ed25519
key to connect to your EC2 instances using your Yubikey for authentication.
Relevant content
- asked a year ago
- asked 4 years ago
- asked 2 years ago
- AWS OFFICIALUpdated a year ago
Hi. My problem is not generating a key ; the question is if and how I can use a FIDO SSH key as shown here : https://developers.yubico.com/SSH/Securing_SSH_with_FIDO2.html