Friday, 31 October 2014

Still Vagranting

This morning I got a bit further with setting up my Vagrant box - I can now access static HTML pages!

The first issue I had today was that I couldn't ssh in with my user. I found this is because I'm passing the password as a parameter when creating the user, and this requires a password encrypted using crypt(3), not a plain password as I was using. But when I tried to use crypt, I got a message that it wasn't installed and I needed to install mycrypt to use it. So how was passwd generating a password if crypt wasn't available?

I tried installing mcrypt, but that gave me crypt(1), not crypt(3). I'm not sure what the difference is, but man useradd does specifically say the password should be The encrypted password, as returned by crypt(3). I then found this resource: Generating Passwords Using crypt(3), which gives a number of options.

I tried the openssl method, and it worked. I don't understand how though, as each time I used it, it gave a different output. Presumably it uses a variable salt, but since the salt is not recorded I have no idea how it can decrypt the password or encrypt subsequent input of a password in the same way for comparison.

After fixing various problems with my nginx install script, I tried testing a webpage, but it didn't work. Unfortunately Fiddler2 didn't show any IP address information, so I couldn't tell whether it was even trying to connect to the Vagrant box.

After restarting Chrome though, Fiddler did give some information. Instead of the webpage I was trying to load, Fiddler output as the response that the connection was refused, and also included the IP address, showing that it was correct. Checking the running process on the Vagrant box ps -A, I found that the frontend Nginx wasn't running. A mistake on my part - I had service nginx reload when it should have been service nginx start.

With that up and running I could now connect OK. The next steps then, are installing my local copies of mysql and php.

In the afternoon I spent ages trying to get a directory protected under apache, but with access to certain files allowed by basic auth. I tried lots of different things, and couldn't understand why they weren't working. Then I realised - my FilesMatch block was never matching because the filename I was matching had brackets in it. After escaping the brackets I got it working how I wanted quite easily.

Installing mysql on my Vagrant box took ages - I would guess at least an hour for building the dependencies, and at least another hour for mysql itself. When it was installed I had some trouble getting it running, and this was due to permissions problems related to having my.cnf located in my shared folder. You can read more about this issue here: vagrant permissions and foldering.

No comments: