SSH public and private keys

Firstly, i apologise if i have posted in a wrong section of the forum. Please let me know which is the correct section my post should go to.

I have to SCP a file from one server(server A) to another (server B). I read around that a secure way is to use public and private keys.

Assuming my username is new2ss and the keys are already generated;and private key stored in new2ss/.ssh/identity and the public key in
new2ss/.ssh/identity.pub

i will then copy the identity.pub to new2ss/.ssh/authorized_keys on the remote machine(server B). ( assuming i am also logged in as new2ss - "scp file1 new2ss@serverB"....)

However, if the remote machine is owned by me, and the username on that machine is not new2ss. ( for eg its 'foreignid'). there will not be a new2ss/.ssh/authorized_keys directory for me to copy the public key to.

What are the possible workarounds?
Create a 'foreignid' on my own server
or ask the sys admin on server B to create a user called new2ss ? so that i can generate another set of keys?

OR is there another better workaround?

You need to put the new2ss public key in /home/foreignid/.ssh/authorized_keys.

Thanks dangral. its working. :slight_smile: