I have two linux instances in gcp and both are in the same project i created a demo.txt file in instance-1 and i want to transfer this file from instance-1 to instance-2, so i came up with this command
scp -i ~/.ssh/my-ssh-key [USERNAME]@[IP_ADDRESS]:[REMOTE_FILE_PATH] [LOCAL_FILE_PATH]
i also created a key using this command in instance-1
ssh-keygen -t rsa -f ~/.ssh/[ssh-key] -C [root]
my ssh-key is located in /root/.ssh
it have two file '[ssh-key]' and '[ssh-key].pub' and i use exactly this command to share file
scp -i ~/.ssh/'[ssh-key].pub' [root]@[externalIP_of_instance-2]:/usr/ /usr/demo.txt
but getting this error.
external_ip_of_instance-2: Permission denied (publickey)
what am i doing wrong?
Thanks