First week of august

Starting out with a weekly blog!

I noticed that writing a full post about a single topic is hard. This causes a sort of numbing to write more in this blog, which I think is a pitty. Therefore, I decided to add a weekly post where I discuss topics to small for a single post.

Table of Contents

Moving to the cloud

Yesterday, I moved my website from my previous host one.com to the cloud. This move was mainly motivated by curiousity, rather than a real advantage for running my website in the cloud. Nonetheless, it did give me more control over the server on which my website is running, the geographic location of the server, and enabled me to used rsync to upload a new blog post.

I opted for digitalocean, because it seemed a lot simpler to get up and running. After creating an account, I created a new project. Actually digitalocean prompted me to make my first project. Notice by the way that you get $100,- for the first 60 days added to your account. After adding the project you are greated with the following screen:

Digital ocean empty project screen

Here, wee need to add a “droplet”. A droplet is a service provided by digitalocean. It is similar to the “bucket” provided by Amazons AWS. For the operating system I chose Ubuntu 18.04LTS because I am quite familiar with it. I chose a basic droplet for $5 dollars per month (it is completly to the left). I didn’t add any volume and chose the location in Frankfurt. The only “demand” I had for the location is that it was in Europe. Then, I created a SSH key on my local machine by running the command:

ssh-keygen -t rsa

You could actually opt for a password protection, that will work fine, however it a lot less secure. After running the above command a public key is created on your computer in the $HOME/.ssh folder called id_rsa. The content of this file needs to be copied in the field from digital ocean. You can print the content of this file to the screen by running:

cat ~/.ssh/id_rsa.pub

Simply select the text and press CTRL + Shift + C and copy the content to the SSH key field. Now press create Droplet at the bottom of the page and your droplet is created.

Now navigate to the droplet you just created by clicking the droplet in the left menu and than on the name of the droplet. You can now power the droplet by clicking the on switch on the right.

Sweet, we now have a Linux machine running somewhere in Frankfurt, however it is not doing anything yet. I wanted it to serve this “static” website, meaning that we only need a simple webserver. However, before doing this I wanted to secure the machine a bit more. I don’t like that the root account is exposed to the internet, even though it is secured with an ssh key pair. Below the on button on the right side of the droplet screen is a console button. Press it and you get a terminal window. Here I added a new user, added it to the sudo group and coppied the key from the root .ssh folder to the newly created user .ssh folder: (replace the “new_user_name” with the name of the user you want to add)

sudo adduser new_user_name
sudo adduser new_user_name sudo
sudo cp ~/.ssh/authorized_keys /home/new_user_name/.ssh/authorized_keys
sudo chown -R new_user_name:new_user_name /home/new_user_name/.ssh

After doing this we can stop the ssh server to allow root logins by opening the file /etc/ssh/sshd_config and replacing the line PermitRootLogin yes with PermitRootLogin no, and finally restart the ssh server:

sudo systemctl restart sshd.service

We can now close the terminal window and open a regular terminal and login with our newly created user.

Now it is time to configure “nginx”, which is a webserver that will host the static website. For this I followed an excellent tutorial from digitalocean, which I rather refere you to than retype it here. Link.

After completing the tutorial by nginx the next thing to do is to upload the website to the droplet. For this I used a program called rsync. I create this website with the use of Hugo, and I assume that you do too:

rsync -av ./public/* ip_of_your_droplet:/var/www/name_of_your_website/html

After this is completed your website is live! However, it is not so nice to have your users navigate to the ip-adres of your droplet, it is better to have a website name. I registered www.wgvanveen.com with NameCheap. In the end it does not really matter where you register your website name. I then followed an excellent tutorial by digital ocean on how you can let the DNS of your website be handled by digitalocean instead of namecheap (the tutorial works for a lot of different providers!) Link. In essence we have to add three custom name-servers to our website name:

  • ns1.digitalocean.com
  • ns2.digitalocean.com
  • ns3.digitalocean.com

After you have done this go back to your digitalocean control panel and navigate to networking. On the first page you will find a box where you can add a domain. Add the domain with and without “www” to your project. After you have done this there is still a step needed, you need to add an entry to the A register where you point the domain name to the ip-adress of your website. In addition to this add a record to the CAA record if you want to enable SSL.

This last step took me long to find out, because if you simply follow the tutorial from digital ocean this step is not mentioned. It is probably a simple step for cloud veterans, which I am clearly not.

After completing this final step your wesbite is up and running in the cloud, and you can easily update it using rsync.

Upgrading an old computer

Last Friday the grandparents of my girlfriend came by and I asked them to bring their laptop. The computer store they went to simply said to buy a new laptop, which is an easy way out, and a costly way out. The computer was an old Toshiba laptop which was designed for windows 8, but was now running windows 10. Surprisingly it had 6Gb of RAM, which is not bad.

The first step in diagnosing the problem is simply opening up the task manager and see what part of of the laptop caused the bottleneck. Unsurprisingly the old spinning hard disk was beeing used at max capacity while the processor and the RAM lay dorment. The simple upgrade was to replace this old spinning hard-disk with a faster SSD. They did not require much in space, so I put in a 240Gb Kingston harddrive.

(sorry for the quality of the image, I didn’t know I would need it.) It took me about 5 minutes to take out the harddrive and swap it out with another. These older laptops are actually really nice, because not everyting is soldered to the motherboard.

After this I neede to put back windows 10, which was a bit of a pain, because I did not have a windows laptop available to make a windows 10 bootable USB. Luckely, I stumbled on a tool called ventoy. After installing it you need to format you USB stick with ventoy. For this you first need to know where your USB stick is on your computer. The easiest way to to this is run lsblk and see in the list which adress your USB stick is (something with /dev/sdY). However, you have to be absolutely sure about the adres, if you have it wrong you can wreck your computer or whipe the wrong harddisk. In the past this happend to me with a backup harddisk. You can create the stick now with:

ventoy -i /dev/sdY

After it is done it will appear as a normal empty usb stick. Just drag and drop the ISO files to the stick. Yes I said files!, you can make a stick containing multiple OS’es. When trying to boot from the stick you are presented with a menu from which you can select the ISO from which you want to boot.

Some small things

After wrapping up my PhD I wanted to get some order back into the home-server, and my laptop. I upgraded my home-server from Ubuntu 16.04 to 18.04, later this week I will upgrade it to the latest LTS version. For my laptop I wanted to switch to manjaro Linux for a while, so I decided to backup everything and just give it a try. The main benefit for me is the rolling release, I hate upgrading to different versions of Ubuntu and now it is fixed for at least my laptop.

I also launched my first Python library: science data structure. Hopefully, in the comming week I can add the Meta class structure!

Thank you for reading, and I hope you found this post somewhat usefull. If you find any errors in this post please send me an email!

Wouter G. van Veen
Wouter G. van Veen
Aspiring developer & scientist

I use computational fluid mechanics to research the fundaments of insect flight.