Una vez tenemos instalado OpenVZ y la herramienta vzmigrate, necesitamos configurar los certificados ssh entre la máquina origen y la máquina destino.
Crear certificados SSH entre servidores
Máquina origen = 10.0.0.50
Máquina destino = 10.0.0.100
“You first have to setup SSH to permit the old HN to be able to login to the new HN without a password prompt.” Es decir, hemos de permitir al viejo hardware node ser capaz de loguearse contra el nuevo, sin usar un password.
En la máquina origen, ejecutamos
1 | <strong>#ssh-keygen -t rsa</strong> |
No hemos de teclear nada cuando nos pide una frase, doble Enter y seguimos. Veremos lo siguiente:
1 2 3 4 5 6 7 8 9 | Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is: xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx root@localhost.localdomain La llave se ha guardado den el directorio /root/.ssh/ |
1 2 3 4 | <strong> # cd /root/.ssh # ls - ls /root/.ssh </strong> |
Veremos el archivo creado
1 2 | 4 -rw------- 1 root root 1743 May 6 10:03 id_rsa 4 -rw-r--r-- 1 root root 408 May 6 10:03 id_rsa.pub |
Copiamos la clave a la máquina destino:
1 | <strong># scp id_rsa.pub root@10.0.0.100:./id_rsa.pub</strong> |
Puede que veamos el siguiente error
1 2 3 4 5 | ERROR! [root@localhost .ssh]# scp id_rsa.pub root@10.0.0.100:./id_rsa.pub @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
Editamos known_hosts y quitamos la línea con la ip destino involucrada. Volvemos a repetir el proceso, y deberíamos poder copiar la llave pública sin problemas.
1 | <strong># scp id_rsa.pub root@10.0.0.100:./id_rsa.pub </strong> |
1 2 3 4 5 6 | The authenticity of host '10.0.0.100 (10.0.0.100)' can't be established. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '10.0.0.100' (RSA) to the list of known hosts. reverse mapping checking getaddrinfo for es failed - POSSIBLE BREAK-IN ATTEMPT! root@10.0.0.100's password: id_rsa.pub 100% 408 0.4KB/s 00:00 |
Nos conectamos ahora al nuevo host, máquina destino. Añadimos la llave pública importada del servidor origen a autorized_keys2 para finalmente borrar el mismo archivo copiado.
1 2 3 4 5 6 7 | <strong> # cd .ssh/ # touch authorized_keys2 # chmod 600 authorized_keys2 # cat ../id_rsa.pub >> authorized_keys2 # rm ../id_rsa.pub </strong> |
Desde el servidor origen:
1 | <strong># ssh -2 -v root@10.0.100</strong> |
Si nos conectamos bien, sin necesidad de teclear el password es que ya podemos utilizar la herramienta vzmigrate.
1 | <strong># /bin/sh /usr/sbin/vzmigrate -r no -v 10.0.0.100 VED_ID</strong> |
Prerequisitos de Vzmigrate
Make sure:
[...] linux remota y accedemos al directorio /root/.ssh. Para ver como se crea este directorio ir a este link. Añadimos el contenido de la llave pública al fichero authorized_keys y [...]