Search code examples
sshssh-keysopenssh

Log In with Openssh Private Key


I got a .pk file, which inside I have a key that looks like this:

-----BEGIN OPENSSH PRIVATE KEY-----

CONTENT

-----END OPENSSH PRIVATE KEY-----
  1. What is a .pk extension file? Perhaps short of private key? Switching the extension to .pem for example, or to none, will make any difference?
  2. How can I ssh with this key. Is it like the regular way? -> ssh -i key.pk user@IP I got the following error: -> Permission denied (publickey)

Solution

  • Yes, "Private Key" is what the abbreviation stands for. You are also correct in thinking that the file types are arbitrary; some organizations use different naming standards.

    Your public key needs to be added to your user's .ssh/authorized_keys file on the remote server before the key pair can be used. If you do not have the public key, the following command will retrieve a public key from a private key:

    $ ssh-keygen -y -f private_key_file > public_key_file.pub