2017-05-09 4 views
1

Comment résoudre ce problème?AWS CLI: la clé n'est pas au format de clé publique OpenSSH valide

# I used this command to create the key with a password 
$ ssh-keygen -b 2048 -t rsa -C "awsfrankfurt" -f ~/.ssh/awsfrankfurt 

# Then when I try to import it into AWS EC2, the error appears: 
$ aws --region eu-central-1 ec2 import-key-pair \ 
    --key-name "awsfrankfurt" \ 
    --public-key-material ~/.ssh/awsfrankfurt 

An error occurred (InvalidKey.Format) when the ImportKeyPair operation: 
Key is not in valid OpenSSH public key format 

Répondre

1

Créez votre clé, puis lorsque vous appelez l'argument --public-key-material de aws, appelez avec file:// devant votre chemin de clé.

Exemple:

$ aws --region eu-central-1 ec2 import-key-pair \ 
    --key-name "awsfrankfurt" \ 
    --public-key-material file://~/.ssh/awsfrankfurt # <-- this 

Ce problème est bizarre, parce que, préfixe file:// est généralement utilisé pour Windows, mais, ici avec aws, il applique aux terminaux à base unix ainsi.