Its my first time using SSH.

How do I go about ssh-ing into a remote system using only the private key for the remote system? I tried ssh-copy-id my generated public key and ssh-ing using the given private key, but both eventually give me: Permission denied (publickey).

  • 1
    So is this about only using the private key (and no other method, like asking for a password), or is this about fixing the cause the prevents you from logging in with the private key? For the latter, the first step is to ssh -v in verbose mode, and look at why the public key is not accepted.
    – dirkt
    Commented Sep 8, 2019 at 9:53
  • The former. It is about ONLY being supplied the private key. Password is turned off on the remote system, so I have no way of getting my public key onto the system. I have seen things in regards to generating the public key from the private key I was given. Does that sound correct? Commented Sep 8, 2019 at 10:08
  • 1
    You need to be able to login to the remote system to install your key, either through SSH or other means. If you can't ssh without already having a key, you'll have to use a different account that has sudo access, or perhaps login as root on the console to install your key.
    – L.Ray
    Commented Sep 8, 2019 at 10:35
  • So, in other words, the fact that I'm not getting access on this account to install my public key means that Public Key Authentication is likely disabled on the account im attempting to connect, correct? While this is disabled, unless I have physical access, I try another account on the remote system, or an admin changes permisions, I cannot ssh into this machine. Is my understanding correct? Commented Sep 8, 2019 at 11:00
  • @Dannyhughes it's not that it's disabled (though it could also be), it's a chicken and egg problem. To allow access using keys, you already need a key, but to install this key you already need the access. So an other way must be found (other account, ask the administrator, etc.).
    – A.B
    Commented Sep 8, 2019 at 11:04

1 Answer 1


In order for ssh-copy-id to successfully copy your public key to the target machine, you need to have password authentication turned on. After you successfully copy your key, you can turn password authentication off and log in using your private key.

Hopefully I understood your problem correctly.

Thanks @doneal24 for the correction.

  • 1
    Minor correction - you want to copy your public key to the target machine. Your private key should be kept as close to your chest as possible and there is no reason for it to leave the originating device.
    – doneal24
    Commented Sep 8, 2019 at 13:43
  • Minor correction, you need another mechanism to login with ssh such as a password. But if you already have another ssh key installed on the account then you can login with that one to install another. Therefore you don't necessarily need password access enabled to use ssh-copy-id Commented Sep 8, 2019 at 15:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .