Per abilitare l’autenticazione ssh tramite chiave pubblica sul virtualizzatore VMware ESXi 5.x basta creare un nuovo file all’interno dell’hypervisor.
Prendiamo come esempio la seguente chiave pubblica dell’utente root :
_ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDfJAIbuQj+T0xD1uA3B1yOqsPCfORhRNLzkrA5OqW1HC2ZTdvgTj/UgP1KJ6UBC3Ux0DRIoEHwoPonG4XdwrSvQVaMYLG4G+kAHwZN5A3IL7D4aNGJPtMPmxfeVdsJHGCO2xIcpPmk/FpcJJW2IF3BlYqJr8sqbo6/odp0kNK83ROuek0Lbaqhs/NE1rxfKbYouko9Rg/DBnKIIIITxWYZuYYqa+uXPzprpb8n6YX5+EkiuTo9to0dyA/M5kYcRrbrv1aYjU2HsmQJiDz+x4KHvHIrAjcf0t9Fu5yLuV0KuiTnzdYL+FojkVNyW/hXNaT4fWI2iKYEaCc7vedqAPiZ [email protected]_
SSH Public key su ESXi 5.x —> Test Connessione senza chiave
Proviamo a stabilire una connessione ssh da una distribuzione linux verso il virtualizzatore ESXi 5.x (10.0.0.3)
[email protected]:~# ssh 10.0.0.3
The authenticity of host '10.0.0.3 (10.0.0.3)' can't be established.
RSA key fingerprint is ac:f3:21:03:c8:26:ed:7f:cd:a2:e5:75:ae:62:69:09.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.0.0.3' (RSA) to the list of known hosts.
Password:
SSH Public key su ESXi 5.x —> Copia della chiave
Per copiare la chiave pubblica verso il virtualizzatore è possibile utilizzare almeno due metodi:
- Trasferimento della chiave tramite scp:
[email protected]:~# scp /root/.ssh/id_rsa.pub 10.0.0.3:/etc/ssh/keys-root/authorized_keys
Password: <--- Inserisci password
id_rsa.pub 100% 395 0.4KB/s 00:00
[email protected]:~#
- Creare il file authorized_keys direttamente sul virtualizzatore
Collegarsi tramite ssh client sul virtualizzatore e creare il file authorized_keys con il comando
[email protected]:~# ssh 10.0.0.3
Password:<--- Inserisci password
The time and date of this login have been sent to the system logs.
VMware offers supported, powerful system administration tools. Please
see www.vmware.com/go/sysadmintools for details.
The ESXi Shell can be disabled by an administrative user. See the
vSphere Security documentation for more information.
~ # vi /etc/ssh/keys-root/authorized_keys
Copiare il contenuto della chiave pubblica all’interno del file e uscire salvando le modifiche.
Attenzione!!! la chiave pubblica deve essere copiata tutta sulla stessa riga
SSH Public key su ESXi 5.x —> Test Connessione con la chiave
[email protected]:~# ssh 10.0.0.3
The time and date of this login have been sent to the system logs.
VMware offers supported, powerful system administration tools. Please
see www.vmware.com/go/sysadmintools for details.
The ESXi Shell can be disabled by an administrative user. See the
vSphere Security documentation for more information.
~ #
SSH Public key su ESXi 5.x —> Disabilitare autenticazione SSH con password
Per accedere al demone ssh dell’ESXi 5 soltanto tramite chiave pubblica si deve editare il file:/etc/ssh/sshd_config e modificare:
ChallengeResponseAuthenticatio yes
PasswordAuthentication yes
in
ChallengeResponseAuthenticatio no
PasswordAuthentication no
Infine riavviare il server ssh:
~ # /etc/init.d/SSH restart
SSH login disabled
SSH login enabled
~ #