Monday, February 10, 2025

openssh use public-key to connect (both server and client was windows)

 server side:

    1 edit sshd_config

        1.1 remove # at line

        PubkeyAuthentication yes

        PasswordAuthentication no   (change yes -->no)

        1.2 add # at two lines of end file

        #Match Group administrators

           #AuthorizedKeysFile __PROGRAMDATA__/ssh/administrators_authorized_keys

    restart openssh service

    3 create file authorized_keys   (c:\user\prapop\.ssh\authorized_keys)

    may be need

    4 remove inherite permission and remove adminostator of file authorized_keys  

client side

    1 ssh-keygen

    2 copy id_rsa.pub (client side) --> authorized_keys (server side)

ssh -N -R 12345:localhost:21118 -o ServerAliveInterval=60 -o ServerAliveCountMax=3 192.168.0.86