ssh con chiave ppk: da putty a linux [RISOLTO]

Postate qui per tutte le discussioni legate a Linux in generale.

Moderatore: Staff

Regole del forum
1) Citare sempre la versione di Slackware usata, la versione del Kernel e magari anche la versione della libreria coinvolta. Questi dati aiutano le persone che possono rispondere.
2) Per evitare confusione prego inserire in questo forum solo topic che riguardano appunto Gnu/Linux in genere, se l'argomento è specifico alla Slackware usate uno dei forum Slackware o Slackware64.
3) Leggere attentamente le risposte ricevute
4) Scrivere i messaggi con il colore di default, evitare altri colori.
5) Scrivere in Italiano o in Inglese, se possibile grammaticalmente corretto, evitate stili di scrittura poco chiari, quindi nessuna abbreviazione tipo telegramma o scrittura stile SMS o CHAT.
6) Appena registrati è consigliato presentarsi nel forum dedicato.

La non osservanza delle regole porta a provvedimenti di vari tipo da parte dello staff, in particolare la non osservanza della regola 5 porta alla cancellazione del post e alla segnalazione dell'utente. In caso di recidività l'utente rischia il ban temporaneo.
Rispondi
Avatar utente
daniele50
Linux 3.x
Linux 3.x
Messaggi: 964
Iscritto il: mar 10 apr 2007, 13:58
Nome Cognome: Daniele Cinquanta
Slackware: Slackware64 14.1
Kernel: 3.10.17
Desktop: Xfce 4.10
Località: San Zenone al Lambro (MI)
Contatta:

ssh con chiave ppk: da putty a linux [RISOLTO]

Messaggio da daniele50 »

Ciao,
sto riaffrontando un problema che avevo risolto tempo da (viewtopic.php?f=2&t=28315&hilit=putty) ma che ora non riesco più a risolvere, neanche rileggendo più volte il vecchio post.

...riparto da zero...

in windows uso putty per collegarmi a server linux e le impostazioni sono queste:
- protocol: SSH
- preferred SSH protocol version: 2
- authentication methods: attemp "keyboard-interactive" auth (SSH2)
- private key file for authentication: C:\privatekey.ppk

ora vorrei collegarmi ale server dalla shell di linux ma non so come fare, ecco cosa succede:

Codice: Seleziona tutto

cindan@cindan:~$ ssh -i /home/cindan/.ssh/privatekey.ppk server.rete.com
Enter passphrase for key '/home/cindan/.ssh/privatekey.ppk': 
ma io non ho passphrase da dargli.

Mi ricordo che dovevo convertire la chiave privata ppk con puttygen (da windows) ma ci sono molte opzioni, ho fatto qualche prova ma arrivo sempre alla stessa conclusione (l'errore sopra citato). Non so come debuggare il problema...


Ecco alcuni dettagli:

Codice: Seleziona tutto

cindan@cindan:~$ ssh -vvv server.rete.com
OpenSSH_5.8p1, OpenSSL 0.9.8r 8 Feb 2011
debug1: Reading configuration data /etc/ssh/ssh_config
debug2: ssh_connect: needpriv 0
debug1: Connecting to server.rete.com [192.168.1.1] port 22.
debug1: Connection established.
debug1: identity file /home/cindan/.ssh/id_rsa type -1
debug1: identity file /home/cindan/.ssh/id_rsa-cert type -1
debug1: identity file /home/cindan/.ssh/id_dsa type -1
debug1: identity file /home/cindan/.ssh/id_dsa-cert type -1
debug1: identity file /home/cindan/.ssh/id_ecdsa type -1
debug1: identity file /home/cindan/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_4.3
debug1: match: OpenSSH_4.3 pat OpenSSH_4*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.8
debug2: fd 3 setting O_NONBLOCK
debug3: load_hostkeys: loading entries for host "server.rete.com" from file "/home/cindan/.ssh/known_hosts"
debug3: load_hostkeys: found key type RSA in file /home/cindan/.ssh/known_hosts:3
debug3: load_hostkeys: loaded 1 keys
debug3: order_hostkeyalgs: prefer hostkeyalgs: ssh-rsa-cert-v01@openssh.com,ssh-rsa-cert-v00@openssh.com,ssh-rsa
debug1: SSH2_messaggio_KEXINIT sent
debug1: SSH2_messaggio_KEXINIT received
debug2: kex_parse_kexinit: ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa-cert-v01@openssh.com,ssh-rsa-cert-v00@openssh.com,ssh-rsa,ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-dss-cert-v01@openssh.com,ssh-dss-cert-v00@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-dss
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib
debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit:                                                                                                                      
debug2: kex_parse_kexinit: first_kex_follows 0                                                                                                  
debug2: kex_parse_kexinit: reserved 0                                                                                                           
debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1                            
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss                                                                                                      
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,zlib@openssh.com
debug2: kex_parse_kexinit: none,zlib@openssh.com
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: first_kex_follows 0 
debug2: kex_parse_kexinit: reserved 0 
debug2: mac_setup: found hmac-md5
debug1: kex: server->client aes128-ctr hmac-md5 none
debug2: mac_setup: found hmac-md5
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_messaggio_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_messaggio_KEX_DH_GEX_GROUP
debug2: dh_gen_key: priv key bits set: 126/256
debug2: bits set: 503/1024
debug1: SSH2_messaggio_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_messaggio_KEX_DH_GEX_REPLY
debug1: Server host key: RSA 47:c5:7d:2f:4f:dd:53:4e:a3:59:04:8e:cd:41:15:c9
debug3: load_hostkeys: loading entries for host "server.rete.com" from file "/home/cindan/.ssh/known_hosts"
debug3: load_hostkeys: found key type RSA in file /home/cindan/.ssh/known_hosts:3
debug3: load_hostkeys: loaded 1 keys
debug3: load_hostkeys: loading entries for host "192.168.1.1" from file "/home/cindan/.ssh/known_hosts"
debug3: load_hostkeys: found key type RSA in file /home/cindan/.ssh/known_hosts:3
debug3: load_hostkeys: loaded 1 keys
debug1: Host 'server.rete.com' is known and matches the RSA host key.
debug1: Found key in /home/cindan/.ssh/known_hosts:3
debug2: bits set: 492/1024
debug1: ssh_rsa_verify: signature correct
debug2: kex_derive_keys
debug2: set_newkeys: mode 1
debug1: SSH2_messaggio_NEWKEYS sent
debug1: expecting SSH2_messaggio_NEWKEYS
debug2: set_newkeys: mode 0
debug1: SSH2_messaggio_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_messaggio_SERVICE_REQUEST sent
debug2: service_accept: ssh-userauth
debug1: SSH2_messaggio_SERVICE_ACCEPT received
debug2: key: /home/cindan/.ssh/id_rsa ((nil))
debug2: key: /home/cindan/.ssh/id_dsa ((nil))
debug2: key: /home/cindan/.ssh/id_ecdsa ((nil))
debug1: Authentications that can continue: publickey,gssapi-with-mic
debug3: start over, passed a different list publickey,gssapi-with-mic
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /home/cindan/.ssh/id_rsa
debug3: no such identity: /home/cindan/.ssh/id_rsa
debug1: Trying private key: /home/cindan/.ssh/id_dsa
debug3: no such identity: /home/cindan/.ssh/id_dsa
debug1: Trying private key: /home/cindan/.ssh/id_ecdsa
debug3: no such identity: /home/cindan/.ssh/id_ecdsa
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
Permission denied (publickey,gssapi-with-mic).
cindan@cindan:~$ 

Codice: Seleziona tutto

cindan@cindan:~$ more .ssh/privatekey.ppk 
PuTTY-User-Key-File-2: ssh-dss
Encryption: none
Comment: dsa-key-20090415
Public-Lines: 10
AAAAB5WzaA1kc3MAAdCBAOfl573Zq+E42bhts0GwQrzZkCzc7eZoUDn9HgX4yY+A
447Jow1msdldjjL+zYOebYOsHCu+Lm/cF2wlFnH6eNQYuEXbl2VD1V7eKTUONN8f
P8GOm9rCu+Lm/cIU2ENOjAbtmFcEmu+itS4dZOKTIBS2xJCIxElQmYfiK9dH0WGP
AAAAFQDqr4o+x0t358ZZu/che+r1+NiCQdQACu+Lm/cGEL/w/616MCthoQoP67dI/
e1YvhYd/kjtL0qYkrFVl8cpRyKCWTjJS6qGDEMaw5DCu+Lm/cFmi3otm+ahxMH2T
jx/U1EYBCu+Lm/ccZGPmwvSxrMYTyQFrC/TtrGTjP2rybQAiYdoE3Ev89jAGAI+xR
iEoRyHXhf9USDJXvNCu+Lm/c4FqfZ65jihRGSn2eW37P9pTjVuLBtJPjwY9Bn7QC
sSs3m0g34/3MfSACbRCMxH0AdGQGtPDeHcxwWuyMUHZWVBfICu+Lm/cFcD11M/GK
kUQBFY8FrdCtFxa3rci2hPrDmViHzMvCu+Lm/cLuUmqohh875BxRaVjj9pB1+LqZZ
Hw==
Private-Lines: 1
AAAACu+Lm/cHpCg7xZPFvxPlRjMAUUwimg==
Private-MAC: 9e55t54dd0ac1122c8a6e5c55ty92d7f1ad9573e
cindan@cindan:~$ 

Se qualcuno sa come analizzare meglio la situazione sono tutto orecchi... grazie!
Ultima modifica di daniele50 il ven 27 mag 2011, 10:43, modificato 1 volta in totale.

Avatar utente
daniele50
Linux 3.x
Linux 3.x
Messaggi: 964
Iscritto il: mar 10 apr 2007, 13:58
Nome Cognome: Daniele Cinquanta
Slackware: Slackware64 14.1
Kernel: 3.10.17
Desktop: Xfce 4.10
Località: San Zenone al Lambro (MI)
Contatta:

Re: ssh con chiave ppk: da putty a linux

Messaggio da daniele50 »

In sostanza ho un file con delle righe pubbliche e delle righe private, posso usare puttygen su linux per convertire la chiave ma non ho idea di che opzioni usare, sono ignorante in materia...

Avatar utente
daniele50
Linux 3.x
Linux 3.x
Messaggi: 964
Iscritto il: mar 10 apr 2007, 13:58
Nome Cognome: Daniele Cinquanta
Slackware: Slackware64 14.1
Kernel: 3.10.17
Desktop: Xfce 4.10
Località: San Zenone al Lambro (MI)
Contatta:

Re: ssh con chiave ppk: da putty a linux

Messaggio da daniele50 »

Ho trovato come fare:

da windows ho usato puttygen.exe, ho impostato la chiave .ppk dal menu File->Load private key e l'ho esportata dal menu Conversion->Export OpenSSH key, a quel punto mi sono portato il file generato da puttigen sulla macchina linux e con il seguente comando mi collego correttamente ai server linux:

ssh user@server.local.com -i filechiavegenerata

ciao a tutti!

Rispondi