Nie udaje mi się uwierzytelnić po ssh za pomocą klucza prywatnego.
Na 1 komputerze (serwer) wsl Ubuntu na windows 10 zrobiłem tak:
- Zainstalowałem open-ssh.
- Zmieniłem konfigurację w
/etc/ssh/sshd_config
odkomentowując:
PubkeyAuthentication yes
AuthorizedKeysFile ~/.ssh/authorized_keys
całość pliku (z usuniętymi komentarzami):
Include /etc/ssh/sshd_config.d/*.conf
PubkeyAuthentication yes
AuthorizedKeysFile ~/.ssh/authorized_keys
KbdInteractiveAuthentication no
UsePAM yes
X11Forwarding yes
PrintMotd no
AcceptEnv LANG LC_*
Subsystem sftp /usr/lib/openssh/sftp-server
Na 2 komputerze (klient) windows 10 zrobiłem tak:
- Wygenerowałem klucz prywatny i publiczny
ssh-keygen
Na 1 komputerze (serwer):
- Przekopiowałem klucz publiczny id_rsa.pub z klienta na serwer do ~/.ssh/authorized_keys
- Zrestartowałem ssh
sudo service ssh restart
Na 2 komputerze (klient):
ssh -i id_rsa <moj uzytkownik>@192.xxx.xx.xx
mimo że podaję mu klucz prywatny to i tak żąda hasła (po haśle wchodzi). Jak dodatkowo w konfiguracji sshd dodałemPasswordAuthentication no
to przy próbuje logowania z kluczem prywatnym dostaję PERMISSION DENIED.
logi serwera:
???
Nie widzę logów na serwerze, powinny być w /var/log/auth.log?
logi klienta:
OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2
debug1: Connecting to 192.xx.xxx.xx [192.xx.xxx.xx] port 22.
debug1: Connection established.
debug1: identity file C:\\Users\\myuser\\.ssh\\id_rsa type 0
debug1: identity file C:\\Users\\myuser\\.ssh\\id_rsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_for_Windows_8.1
debug1: Remote protocol version 2.0, remote software version OpenSSH_8.9p1 Ubuntu-3ubuntu0.10
debug1: match: OpenSSH_8.9p1 Ubuntu-3ubuntu0.10 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 192.xx.xxx.xx:22 as 'myuser'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:/cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
debug1: Host '192.xx.xxx.xx' is known and matches the ECDSA host key.
debug1: Found key in C:\\Users\\myuser/.ssh/known_hosts:8
debug1: rekey out after 13421778 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 13421778 blocks
debug1: pubkey_prepare: ssh_get_authentication_socket: No such file or directory
debug1: Will attempt key: C:\\Users\\myuser\\.ssh\\id_rsa RSA SHA256:xxx/xxxxx explicit
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,sk-ssh-ed25519@openssh.com,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ecdsa-sha2-nistp256@openssh.com,webauthn-sk-ecdsa-sha2-nistp256@openssh.com>
debug1: kex_input_ext_info: publickey-hostbound@openssh.com (unrecognised)
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering public key: C:\\Users\\pt\\.ssh\\id_rsa RSA SHA256:xxxxxxxxxxxxxxxxx explicit
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: password
debug1: read_passphrase: can't open /dev/tty: No such file or directory
Nie widzi klucza publicznego? debug1: pubkey_prepare: ssh_get_authentication_socket: No such file or directory
?
Jakieś pomysły?
4w0rX4t4X4w0rX4t4X