As of GNU coreutils 7.5 released in August 2009, sort
allows a -h
parameter, which allows numeric suffixes of the kind produced by du -h
:
du -hs * | sort -h
If you are using a sort that does not support -h
, you can install GNU Coreutils. E.g. on an older Mac OS X:
brew install coreutils
du -hs * | gsort -h
From sort
manual:
-h, --human-numeric-sort compare human readable numbers (e.g., 2K 1G)
Don't use a password. Generate a passphrase-less SSH key and push it to your VM.
If you already have an SSH key, you can skip this step…
Just hit Enter for the key and both passphrases:
$ ssh-keygen -t rsa -b 2048
Generating public/private rsa key pair.
Enter file in which to save the key (/home/username/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/username/.ssh/id_rsa.
Your public key has been saved in /home/username/.ssh/id_rsa.pub.
Copy your keys to the target server:
$ ssh-copy-id id@server
id@server's password:
Now try logging into the machine, with ssh 'id@server'
, and check-in:
.ssh/authorized_keys
Note: If you don't have .ssh dir and authorized_keys file, you need to create it first
to make sure we haven’t added extra keys that you weren’t expecting.
Finally, check to log in…
$ ssh id@server
id@server:~$
You may also want to look into using ssh-agent
if you want to try keeping your keys protected with a passphrase.
Best Answer
You can use rsync to essentially clone the whole system via SSH while running.
You create the local VM with the specs you need, install a minimal debian (same version) with the same partitioning schema as your VPS and then boot into a live CD (ubuntu-desktop has pretty much anything you will need).
Then from the live CD you mount the partition(s) to a temporary location (eg: /mnt) and then you run something like this to clone the whole VPS to your local VM keeping all permissions intact.
Make sure to exclude paths that you don't need to clone. The above paths are standard paths that need to be excluded for a successful rsync.
Depending on the virtualization platform the current VPS runs on you might need to fix some paths or files (eg: Partitions' UUIDs on
/etc/fstab
and/or GRUB config).You may also need to (re)install the boot loader.
And of course you will need to update the network information so that the newly cloned VM is accessible over the network.