I've done exactly what you are looking to do. The way I did it is outlined below. Is it the correct way? Well... that's up for debate, but it works for me. Hope it helps you. Also, I'm not on Ubuntu, but it should work the same on Ubuntu
First, I setup Yubikey configuration by editing /etc/ykfde.conf
set YKFDE_CHALLENGE to a long random string like 40 characters or so. It doesn't matter what it is, just make sure it's random. This allows me to decrypt my drive without it asking me for a secret password. Also, set YKFDE_CHALLENGE_SLOT to whatever slot on your Yubikey you want to use. (Make sure you've setup your Yubikey for HMAC-SHA1 challenge response on that slot)
Next, I setup my drive to be encrypted with the following commands:
(this assumes that you've already partitioned your drive with fdisk or a similar utility)
# This will ask you for a password. Set a password so that you
# can decrypt the drive without your Yubikey
sudo cryptsetup luksFormat /dev/sda1
# Next, enroll the Yubikey so that it can decrypt it as well
# When required, touch your Yubikey so it can get a challenge-response
# It'll ask for an existing password, just enter the one you set in the last command
sudo ykfde-enroll -d /dev/sda1 -s 1
# Next decrypt the drive and add a file system
# Enter the password you set in the first command
sudo cryptsetup open /dev/sda1 drive
sudo mkfs.ext4 /dev/mapper/drive
After all the setup was done, I created a file called mountDrive.sh in my home directory as follows:
. /etc/ykfde.conf
ykchalresp -2 "$YKFDE_CHALLENGE" | sudo cryptsetup open /dev/sda1 drive
sudo mount /dev/mapper/drive /run/mount/
Now, I simply run sh mountDrive.sh
My Yubikey flashes, I tap it, and then my drive is mounted at /run/mount
Obviously, you'd need to change /dev/sda1 to whatever your drive device is and change /run/mount to wherever you want to mount your drive
Also, the ykchalresp -2 command tells it to use slot 2 on my Yubikey. Change that to whatever slot you have configured in your /etc/ykfde.conf file
One more thing is that I setup /etc/sudoers so that I can use sudo without having to type in my password. Perhaps there is a better way to do it without having to use sudo to decrypt and mount your drive... not sure... anyway, here's how I set that up:
Add %wheel ALL=(ALL) NOPASSWD: ALL to the /etc/sudoers file.
Add your account to the wheel group like:
me=`whoami`; sudo usermod -a -G wheel "$me"