16 Dec 2015
In a previous post I talked about how I needed to move away from shared hosting to a server where I could get root access. Initially I looked at getting a VPS with Hostgator, but the prices seemed too steep for me with the specs they were offering. I then started to shop around, trying to find a VPS with a reasonable price to performance ratio. There are a ton of providers out there, some of course better than others. My first port of call was DigitalOcean who are a very popular provider of servers. For around £10 per month you can get 1GB of RAM and 1 processing core. They are very good if you want to spin up a server for a few hours, but as I intended on having mine up 24/7, I again thought I could do better price wise.
I then visited OVH who are known to provide extremely cheap VPS’s. At the time of writing, for around the same price you can get 2 vCores, 8GB of RAM and 40GB of SSD disk space. They certainly do live up to their reputation. They are known to not provide the best support on the market, but for that price I think that’s quite reasonable. Besides, I don’t really want to rely on support to fix my software issues - it’s definitely good experience to figure out Unix issues yourself (and I definitely have had to).
I was just about to order myself a VPS with OVH when I got linked to one of their partners - Kimsufi. They are a separate company yet their servers are located in OVH’s datacentres so you still get access to their extensive infrastructure. Kimsufi don’t really market their servers towards commercial needs, their website targets training, hosting and sandboxing - perfect! Kimsufi offer a set of 7 dedicated server models for crazy prices considering their specs (yes, that’s right they are dedicated not VPS’s). For around £12 you can get yourself a Core i5 and 16GB’s of RAM or for just £25 per month you can get yourself dual Xeon processors and 24GB’s of RAM - crazy right? The low price does of course come with it’s drawbacks. Kimsufi will tell you themselves that they offer barebones support. If you have a software problem, then expect to have to fix it yourself. Of course they will still fix your server’s hardware if it fails at any point. I settled on the KS-3 model which gives you your very own dedicated server with:
- Intel Core i5-3570s @ 3.10GHz (4 cores)
- 16GB RAM
- 2TB Disk Space
- 100 Mbps network link (unmetered)
- 1 dedicated IPv4 and Ipv6 address
It was a little more than I wanted to pay, but who doesn’t want their own dedicated quad core server? With these specs I was also able to set up a lot more software than I initially intended and I never have to worry about the performance implications. Although I wanted to get hold of a Kimsufi server, it wasn’t that easy however, if you look at their website you will most likely see that all of the models are currently being replenished. They do become available every so often, but they sell out again almost immediately. Handily, there are a couple of websites which will alert you when a particular model becomes available so you can pounce as fast as possible:
Whenever you get an alert email make sure you take action straight away. It takes some effort to get hold of one these servers. Also expect the ordering process to fail right at the end when they sell out whilst you are ordering (they don’t reserve you one during checkout). It took a while, but eventually I got hold of a KS-3 and I’ve been very happy with it so far (~6 months). In the end my processor was even better than the one they advertise and otherwise you get exactly what you pay for. The control panel is simple but functional (I’ve never really needed use it apart from when installing an initial Linux distribution) and the network speeds are great. I’ve had a lot of fun and learnt a load setting up and configuring a Linux server (I will post more about this in the future). If you are looking to do the same and want to get your hands on a dedicated server, then I would definitely recommend you check out Kimsufi.
11 Dec 2015
Handily, there is an open source project on GitHub that provides a command line interface for testing internet bandwidth using speedtest.net. The only prerequisite is that you have Python installed (any version between 2.5 and 3.4 will do).
The project provides many different methods of installation such as
easy_install. You can also clone the Git repository onto your machine somewhere. These will all work fine, however as the script is just one file, you can simply use
curl/wget to download and run it directly. Using
wget, the commands to download the script and make it executable are:
$ wget -O speedtest-cli https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest_cli.py
$ chmod +x speedtest-cli
Then, just run the script using
python speedtest-cli. Just like speedtest.net, the script will choose the closest server to your machine and begin a download/upload test. The results are then output into your terminal window:
user@machine:~/speedtest_cli$ python speedtest-cli
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Selecting best server based on latency...
Hosted by Heberg.fr (Roubaix) [0.72 km]: 4.621 ms
Testing download speed........................................
Download: 93.98 Mbit/s
Testing upload speed..................................................
Upload: 91.33 Mbit/s
There are also some additional switches that let your define which server you wish to use for the test. First, you need to find the corresponding id using
python speedtest_cli --list. This will output a long list (probably best to redirect this into a file) of servers and id’s. Make a note of the id you want to use and then run the command again, this time supplying said server e.g.
python speedtest_cli --server <ID>.
For more information, visit their GitHub page at https://github.com/sivel/speedtest-cli.
06 Dec 2015
Amongst one of the best plugins available for Sublime Text 2 & 3 is the SFTP plugin from wbond (who is known for other great plugins including Alignment, SVN and Package Control itself). The SFTP plugin negates the need for using another dedicated SFTP client such as FileZilla when editing documents on a remote server. From the site, it’s features include:
- Work off of a server - edit and manipulate files and folders
- Map a local folder to a remote folder
- Publish files, folders, or just the changes since your last commit
- Sync folders - up, down or both directions
- Diff local vs. remote versions of a file
- Other operations and options to help you get stuff done
- Password and SSH key auth with SSH agent support
- Persistent connections for performance
To install, simply open up Package Control through
Install Package and select
SFTP. You then have to configure the plugin for use on your current project. This is done through the SFTP/FTP context menu on the right click context menu of your root directory. Once configured, a
sftp-config.json file will be created. This is where you tell the plugin where to map your local directory to on the remote server. The main changes I make are:
- Make sure
type is SFTP not FTP (we like security)
- I like to set
upload_on_save to true so the most recent copy is pushed to the server whenever I save a file (great timesaver)
host to point to your remote servers IP/domain
user to whatever user you have SFTP (SSH) setup for on your server.
port to whatever port you have SSH running on (you shouldn’t really be running on the default 22)
remote_path should point to the directory you want to push changes to on your remote server e.g.
Finally, you will want to make sure you are authenticating in some way. You could use a password, but you really should be using public key authentication. As such, change the
ssh_key_file property to point to the absolute path to your key file. This caused me some confusion initially as I used the
id_rsa OpenSSH key I use for SSH under Cygwin. For *nix systems this should work fine, however on Windows it turns out that Sublime uses PSFTP (PuTTY SFTP) instead, so it expects a PuTTY private key file (
.ppk extension). If you get a lot of
Connection Refused errors from Sublime and
No authentication found errors in the SSH logs, this could be the reason. If all is setup correctly, you should be able to push files to the remote server.
The SFTP/FTP menu also provides some additional options such as Syncing your Remote/Local directories and Browsing your remote. Note that this is the ‘Remote’ workflow whereby you are editing a copy of the files on your local machine. There is also a ‘Server’ workflow which allows you to work directly off the server.
Just like Sublime Text itself, the plugin is not officially free. However, the trial never ends - just prompts you to purchase every so often. For more information on the plugin, visit the official page https://wbond.net/sublime_packages/sftp.
01 Dec 2015
In a new installation of Cygwin, your home directory will be in
C:/cygwin/home/<user>/, and can be accessed by the usual
~ shortcut. Although this works just fine, it’s often useful to use the utilities provided by Cygwin in your local Windows user area
C:/Users/<user>. Manually navigating to your Windows home directory can be a tedious process as you also have to go through
cygdrive. By default, to access your Windows area in Cygwin you would navigate to
/cygdrive/c/Users/<user>. Alternatively, you can just change your Cygwin home directory to be the same as Windows for easy access to all your files.
There are numerous posts on the Internet about how to accomplish this but the accepted methods always seems to change alongside Cygwin versions. Common solutions tend to involve the
mkpasswd command, various environment variables, shortcuts and even registry edits. Thankfully, it seems that in the newer versions of Cygwin, there is a much easier way which requires one simple edit to a configuration file.
Navigate to the
/etc/nsswitch.conf file in your installation folder (this should be something like
C:/cygwin/etc/nsswitch.conf). Open it up in your favourite text editor and make the following change to the
db_home property. This change simply points your Cygwin home to your Windows home using the
%H variable. After the change, the file should look like this:
# passwd: files db
# group: files db
# db_enum: cache builtin
# db_shell: /bin/bash
# db_gecos: <empty>
And that’s it. Fire up a new Cygwin terminal and you should see that the default directory is now your Windows home directory. As expected,
~ also now points to your Windows home area.
26 Nov 2015
After frequently using the ‘Open command window here shortcut’ in Windows Explorer to open up a command prompt window in the current directory, I found it cumbersome not to have the option to open a Cygwin (or Bash) prompt as well, especially considering how I now find myself using Cygwin more and more often.
There are registry edits that you can do to get similar functionality, but it’s much easier to just use one of the packages bundled with Cygwin. Open up the Cygwin installer and select the
chere package under
Shells. It’s a very small package and so should install relatively quickly.
After that it’s just one command to add the new entry to the right-click context menu in Windows Explorer. Open up a new Cygwin terminal as administrator (this is important!) and run:
chere -i -t mintty
This will add a new entry to open up a mintty (bash) shell at the current directory. There are also options to specify the shell to open (
-s zsh etc) and the text in the shortcut (
-e "Custom text" etc). If completed successfully, you should see a new ‘Bash Prompt Here’ context menu entry: