Can we use a server's own private key from .ssh folder to SSH into it?
I have a remote server:
hostname = rserver.com
port = 22
user = john
The remote server has a key pair id_rsa.john
and id_rsa.john.pub
stored in ~/.ssh/
with proper permissions.
Assume that I somehow get hold of the private key of the remote server (id_rsa.john
).
Can I use the private key of the remote server (id_rsa.john
) from my local machine to SSH into the remote server?
Solution 1:
The key in the ~/.ssh/
folder is not server's key. It's your own key stored on the server. You are free to use your own key for as many accounts/servers as you like.
Though, a mere presence of the private key file on the server (anywhere) has no effect on the authentication to that server. To authenticate to the server using the key, you have to add its public key to the authorized_keys
file, as with any other key.
The server's own keys (assuming Linux/OpenSSH) are stored in /etc/ssh/
and you absolutely should not use them anywhere else