DEV Community

Cover image for SSH Authentication issues: Permission denied(publickey)
makhosii
makhosii

Posted on • Edited on

SSH Authentication issues: Permission denied(publickey)

Assumptions

  1. The author assumes that that you are trying to ssh into a server or (git server) using a public key instead of a passphrase.
  2. You have generated a ssh key on your local machine.
  3. You have transferred the ssh key to the server, and your OpenSSH server is configured.

Method 1

If your key is not saved in .ssh/id-rsa or if you have more than one ssh key on your local machine. Then have to mention the location of your key using the i flag (-i)

ssh user@192.168.1.101 -i ./.ssh/id_rsa_supremee_key

Method 2

Or better yet, you can configure the OpenSSH client.

On windows the config file is found at C:\Users\username\.ssh\config. So head to this file and add the key\values below, (obviously yours will be different)


#Personal account, - the default config
Host makhosi6.github.com
   HostName github.com
   User git
   IdentityFile ~/.ssh/id_rsa

#work account 
Host dev.github.com  
   HostName github.com
   User git
   IdentityFile ~/.ssh/id_rsa_dev

#supremee
Host 192.168.1.102
   HostName 192.168.1.102
   IdentityFile ~/.ssh/id_supremee_key

Enter fullscreen mode Exit fullscreen mode

References

www.digitalocean.com
nerderati.com
ssh.com
linuxize.com
thereference.dev

Top comments (0)