SSH keys- stupid simple question

I’ll preface this with something like “this is really simple, but I can’t find an exact answer”.

I was working through the “Getting started” path and was on the privilege escalation portion of the lab. This was the part where you needed to move from user1 (the user you initial log in as), then move to user2 (because of no password on /bin/bash), then up to root and you grab the flag.

I got to a point where I read the private key in root’s .ssh folder within 2-3 minutes, then copied the content over and pasted it into my existing id_rsa key, since I already did ssh keygen a few minutes prior (assuming I’d need to use keys). I did chmod 600, figuring I’d be done in 30 seconds, but I kept getting an error asking for password. I ended up creating a totally new id_rsa file outside of my .ssh folder and using that, but my question is this: why exactly does it not work if I just replace the contents of id_rsa? Is there some relationship here with authorized hosts and the public key? Since I had the contents of the private key belonging to the server’s root account, I figured I’d just paste those into my existing private key, but that obviously didn’t work and cost me 45 minutes of trying to figure out what happened before just creating a blank file with nano.

Thanks

You need to put the root key in a file not your own id_rsa, but just call it root_rsa. Then instead of specifying a username you specify the root_rsa to log in.
ssh -help will you the way.

But if im not wrong, is ssh -i id_rsa. so replace id_rsa by what ever you call the stolen key.