SSH Still Asks for Password with Public Key Setup

Jim Davis 1 Reputation point
2021-02-10T17:35:41.847+00:00

I want to ssh to my linux hosting server without having to enter the password. After hours of research I believe the following steps are correct, but I still get prompted for a password every time

Windows Version 20H2 10.0.19042

Generate Key and add to service-agent
ssh-keygen
keys in Users/$USERNAME/id_rsa id_rsa.pub
ssh-add id_rsa

Transfer Public Key to hosting server
scp -P 1111 id_rsa.pub user@myhost.com:~/.ssh

Set permission on host folders from
chmod 700 ~/
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

I have not found any other necessary steps, but I still get prompted for a password. Any idea of a solution?

Windows 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
11,198 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Mico Mi 1,921 Reputation points
    2021-02-11T06:09:56.287+00:00

    Hi,
    Since I'm not familiar with SSH, I did some research and found some similar threads, and I hope them could help at your side:
    Why am I still getting a password prompt with ssh with public key authentication?
    ssh prompts for password despite .ssh/authorized_keys
    Still prompted for a password after adding SSH public key to a server

    Thanks for your time!
    Best Regards,
    Mico Mi

    -----------------------------

    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. claudiu.cruceanu 1 Reputation point
    2022-04-21T10:09:51.963+00:00

    The first misyake I see is that you copy the public key of the host to remote server using the same name:
    scp -P 1111 id_rsa.pub user@myhost.com:~/.ssh
    You chould copy only if there is only one host to allow to ssh to the server. Ayway you should use a different name:
    scp -P 1111 id_rsa.pub user@myhost.com:~/.ssh/authorized_keys

    P.S.
    More appropriate is to append all public keys of the hosts to be allowed to ssh to the same server.

    0 comments No comments

  3. malcom dickens 1 Reputation point
    2022-08-18T06:10:34.757+00:00

    Hi,

    All you have to do is go to the config file and change the directory file that windows sshd is looking for.

    My file was located in the %ProgramData% folder and then in the ssh folder, there is a config file.

    Change the folder and filename to match ".ssh/authorized_keys" if you keep your file name default for "authorized keys" in the .ssh folder.

    I fixed mine after searching all over smh.

    0 comments No comments