Hi All,

Well I couldn't find any tutorials on the net that really helped us migrate our VPS's to a new node. So with the spare time I got now I'll write up a quick tutorial.

With your previous HW node run the following commands:
$ nano /usr/local/bin/ssh-keyput

Enter this into the file
# ssh-keyput -- set up passwordless openssh login.
# Copyright (C) 2001, 2002, 2006 by SWsoft.
# Author: Kir Kolyshkin
# This script is used to put your public ssh keys to another host's
# authorized_keys[2], so you will be able to ssh login without entering
# a password. Key pairs are generated if needed, and connectivity
# is checked after putting the keys.
PROGNAME=`basename $0`
function usage()
	echo "Usage: $PROGNAME [user@]IP [[user@]IP ...]" 1>&2
	exit 0
# Check for correct number of parameters
test $# -gt 0 || usage;
SSH_KEYGEN=`which ssh-keygen`
if test $? -ne 0; then
	# Error message is printed by 'which'
	exit 1
if ! test -d $SSH_DIR; then
	mkdir $SSH_DIR
chmod 700 $SSH_DIR
if [ ! -f $SSH_DIR/identity ] || [ ! -f $SSH_DIR/identity.pub ]; then
	echo "Generating ssh1 RSA keys - please wait..."
	rm -f $SSH_DIR/identity $SSH_DIR/identity.pub
	$SSH_KEYGEN -t rsa1 -f $SSH_DIR/identity -P ''
	if [ $? -ne 0 ]; then
		echo "Command \"$SSH_KEYGEN -t rsa1 -f $SSH_DIR/identity" \
			 "-P ''\" failed" 1>&2
		exit 1
	echo "ssh1 RSA key is present"
if [ ! -f $SSH_DIR/id_dsa ] || [ ! -f $SSH_DIR/id_dsa.pub ]; then
	echo "Generating ssh2 DSA keys - please wait..."
	rm -f $SSH_DIR/id_dsa $SSH_DIR/id_dsa.pub
	$SSH_KEYGEN -t dsa -f $SSH_DIR/id_dsa -P ''
	if test $? -ne 0; then
		echo "Command \"$SSH_KEYGEN -t dsa -f $SSH_DIR/id_dsa" \
			 "-P ''\" failed" 1>&2
		exit 1
	echo "ssh2 DSA key is present"
SSH1_RSA_KEY=`cat $SSH_DIR/identity.pub`
SSH2_DSA_KEY=`cat $SSH_DIR/id_dsa.pub`
for IP in $*; do
	echo "You will now be asked for password for $IP"
#	set -x
	ssh -oStrictHostKeyChecking=no $IP "mkdir -p ~/.ssh; chmod 700 ~/.ssh; \
		echo \"$SSH1_RSA_KEY\" >> ~/.ssh/authorized_keys; \
		echo \"$SSH2_DSA_KEY\" >> ~/.ssh/authorized_keys2; \
		chmod 600 ~/.ssh/authorized_keys ~/.ssh/authorized_keys2"
#	set +x
	if test $? -eq 0; then
		echo "Keys were put successfully"
		echo "Error putting keys to $IP" 1>&2
for IP in $*; do
	for ver in 1 2; do
		echo -n "Checking $IP connectivity by ssh$ver... "
		ssh -q -oProtocol=${ver} -oBatchMode=yes \
		  -oStrictHostKeyChecking=no $IP /bin/true
		if [ $? -eq 0 ]; then
			echo "OK"
			echo "failed" 1>&2
$ cd /usr/local/bin/
$ chmod a+x ssh-keyput
$ /usr/local/bin/ssh-keyput [email protected] (new HW Node IP)

Both nodes need to be running OpenVZ, there are many tuts on the net on how to install OpenVZ so I won't bother re-writing.

Now for the transfer:
--remove-area yes/no (Do you want to keep the VPS on the previous node)
--ssh="-p [port number]"
--online (The VPS will not go offline during the transfer)
-v (Post output of transfer)

So I ran the following commands:
$ vzmigrate --remove-area no xxx.xxx.xxx.xxx (New Node IP) VPSID

If you want to migrate the VPS and have the ID changed on the new node here is an example

$ vzmigrate --online 100:2000

Where 100 is the VPSID on the old node, and 2000 will be the VPSID on your new node.

My new HW node did not have a new SSH port so I did not add in the --ssh command.

Please do note: If both VPS's are on the same network I don't recommend using the --online command. As IP conflicts may occur.

I hope this helps some people, as I myself could not find a lot on the internet regarding this topic.

Oh btw, use this script without warranty. I'm not responsible if a VZ gets corrupted during transfer or something (I just merely use it)