Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to send a public key to an EC2, without use the ec2-* api commands, and I can't.

I've tried scp and ssh-copy-id, but booth can't use the -i parameter to connect using the keypairs.

The ssh-copy-id -i parameter are the file (public key) to be sent.

What can I do to upload it?

share|improve this question
scp does support -i. What command did you try to run and what's the output? – dfranke Nov 15 '10 at 3:46
I'm also not clear on exactly what you're trying to do. Are you trying to launch an instance with an ssh key that you generated locally, or do you have an already-running instance that you're trying to install a second key onto? – dfranke Nov 15 '10 at 3:47
dfranke. I can connect to the instance at this time, using ssh -i file.pem. But I need make a cron in the client side with rsync, then, I need to have acess withou autentication. – TiagoGouvea Nov 15 '10 at 12:32
I create the public keys in the client side but I can't send it to server. It's the only problem. How to send my public keys from client to server. :( I think it's simple, but at this time I can't. – TiagoGouvea Nov 15 '10 at 12:34
@TiagoGouvea scp does support -i. You can use it as scp -i your_pem.pem your_file user@aws_ip:/home/user/. You probably be getting error because of your permissions on your pem file. It should be 400 (i.e. chmod 400 your_pem.pem) – guleria Feb 17 at 7:38

Ok! I found an way.

In the client side:

cat ~/.ssh/ | ssh -i aws.pem ubuntu@ip_address "cat - >> ~/.ssh/authorized_keys2"

All done!

share|improve this answer
What is the actual problem you're trying to solve that leads you to thinking this is the way to solve it? – bobmagoo May 22 '14 at 15:00

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.