I have an ec2 instance which I can connect using this command with the ssh_key.pem file I have.
ssh -i ssh_key.pem firstname.lastname@example.org
I am trying to use ssh-copy-id to add the public key I have on my local machine to remote ec2 instance.
ssh-copy-id -i .ssh/id_ed25519.pub email@example.com
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: ".ssh/id_ed25519.pub" /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys firstname.lastname@example.org: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
But, it is not working, I guess because I didn't provide any parameter of my private key to connect.
But, I am not able to see any such parameters in the help -h also.
Please suggest how to do so.
ssh-copy-id is not working as mentioned but I found one alternative.
I can connect to the remote machine using the pem file 3.pem
ssh -i 3.pem email@example.com
So, I tried below scp command.
scp -q -i 3.pem .ssh/id_ed25519.pub firstname.lastname@example.org:~/.ssh/authorized_keys
Now, this worked and I am able to login with my key generated.
ssh -i .ssh/id_ed25519 email@example.com
But, it replaces access to 3.pem, earlier key. Because it replaces all the content in the authorized_keys file as I am just copying the file and it replacing the old file.
How to make sure, only append happens.