Using SCP to copy the private key

#1

Hi,

I am installing CHEF Server and Workstation via the course online on the Chef website
I am trying to do the following:
scp -i ~/.ssh/private_key ubuntu@ec2-34-245-200-11.eu-west-1.compute.amazonaws.com:/drop/chefadmin.pem ~/learn-chef/.chef/chefadmin.pem

However, i am getting:

Warning: Identity file /home/ubuntu/.ssh/private_key not accessible: No such file or directory.
Permission denied (publickey).

Any ideas?

#2

You're doing this as the root user? And you used "sudo" to become the root user?

Use 'sudo -i" or "sudo -H" to reset your home directory when you become another user.

#3

Hi nkadel

I tried as you suggested with a sudo -i and it brought me to root.

Warning: Identity file /root/.ssh/private_key not accessible: No such file or directory.

The authenticity of host 'ec2-34-247-189-114.eu-west-1.compute.amazonaws.com (17.2.31.44.35)' can't be established.

ECDSA key fingerprint is SHA256:q2qbL3bk6EoVBhfox8zuicGZl5bzoG8SJRNkx0iB6Go.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added 'ec2-34-247-189-114.eu-west-1.compute.amazonaws.com,172.31.44.35' (ECDSA) to the list of known hosts.

Permission denied (publickey).

Any ideas?

When I do a ls on the ~/.ssh/
I see the file authorized_keys file but there is no private_key. Inside this file there is a reference to anthonyawslabs.

Thanks for your help.

#4

By the way, the knowledge is very limited,

When I run this command
"root@ip-172-31-33-79:~# scp -i ~/.ssh/authorized_keys ubuntu@ec2-34-247-189-114.eu-west-1.compute.amazonaws.com:/drop/chefadmin.pem ~/learn-chef/.chef/chefadmin.pem"

I get the following:
Enter passphrase for key '/root/.ssh/authorized_keys':

Thanks for your help.