Using curl to access an ftp server

When I’ve been spinning up new VMs recently I’ve found that ftp isn’t installed by default on minimal set-ups, but I’ve had to access an ftp server in order to get archive files and the like.

So, while it is pretty easy to install ftp, I’ve found out that you can do most stuff I need via curl. This is pretty handy, and curl gives more information about the download (‘get’) progress.

If you know the exact path to the file you want to download (I’m only looking at downloading for now), then this is all you need:

$ curl -O 'ftp://username:password@ftp.example.com/path/to/myfile'

This is great but sometimes I need to work out where the file I need is on the server, so do I still need ftp?

No – curl can handle this for you too:

$ curl 'ftp://username:password@ftp.example.com/'

Note that you need the trailing slash ‘/’ to get an ‘ls -l’ style list, also drop the ‘-O’ parameter.

Creating a Vagrant Base Box

I’m assuming you’re familiar with Vagrant – it makes provisioning a VM simple. Read more: http://docs.vagrantup.com/v2/why-vagrant/index.html

Now there are a number of available base boxes for building VMs – which can be found here: http://www.vagrantbox.es/

I’ve just been baking my own base box – building a minimal Centos 6 VM on VirtualBox…

  • I first built a basic Centos 6.5 VM w/ minimal packages. (I added openssh-clients for ssh/scp client later to allow access to other machines.)
  • As root added vagrant user – password vagrant.
  • Gave vagrant user full sudo access (with no password). Gotcha I hit later was I that I did not add an override for the ‘requiretty’ option in sudoers. You need both these lines:
vagrant ALL=(ALL) NOPASSWD:ALL
Defaults: vagrant !requiretty
$ ls -la ~vagrant/.ssh/
total 12
drwx------. 2 vagrant vagrant 4096 Feb 15 13:48 .
drwx------. 3 vagrant vagrant 4096 Feb 15 14:11 ..
-rw-------. 1 vagrant vagrant 409 Feb 15 13:46 authorized_keys
  • Mount and install VirtualBox guest additions (see: http://wiki.centos.org/HowTos/Virtualization/VirtualBox/CentOSguest) – perhaps should not have installed ‘Development Tools’ group for this (added a lot of ‘bulk’ to my previously minimal VM, next time go more minimal). Also, no X-Windows set-up – so GUI drivers failed to build.
  • Now can package box. Had problems at first, but it appears that Vagrant 1.4.2 has a bug which stops the packaging – use 1.4.3.
$ vagrant package --base "Centos 6 (64) minimal" --output centos-6-64-min.box

More info can be found here: http://docs.vagrantup.com/v2/boxes/base.html

And here for VirtualBox: http://docs.vagrantup.com/v2/virtualbox/boxes.html