Copy SSH Public Key from Windows to Ubuntu

  • I am trying to get my ssh public key from my windows client to ubuntu host, but I have no idea how to. I tried to find the authorized_keys file, but had zero success. ssh-copy-id command did not work from windows. I generated the public/private key pair in PuTTYgen. I am using OpenSSH on the Ubuntu host. Any ideas on what to do?

  • Baptiste

    Baptiste Correct answer

    4 years ago

    Any ideas on what to do?

    1. EDIT Download cmder or use your favorite console emulator. Move your public key ( and your private key (id_rsa) to C:\Users\yourUserName\.ssh\ create the .ssh folder if needed.

    2. On your windows host via cmder:

    cp C:\Users\yourUserName\.ssh\ C:\Users\yourUserName\authorized_keys

    3. On your ubuntu host:

    service ssh status Start sshd if necessary

    mkdir ~/.ssh/ (if it doesn't already exist)

    4. On your Windows host via cmder:

    cd C:\Users\yourUserName\

    scp authorized_keys [email protected]:~/.ssh

    5. On your Ubuntu host:

    chmod 700 ~/.ssh

    chmod 600 ~/.ssh/authorized_keys

    6. On your Windows host via cmder:

    Test if you can ssh into your ubuntu host without login/pw auth. If yes:

    rm C:\Users\yourUserName\authorized_keys

    (you might encounter difficulties running your ssh-agent on windows, write a comment if so)

    Are you sure that PuTTYgen has generated a C:\Users\yourUserName\.ssh\

    True, gonna edit the answer.

License under CC-BY-SA with attribution

Content dated before 7/24/2021 11:53 AM