Skype forgetting login details on Ubuntu

TLDR; Install gnome-keyring

If you are not using the default install of Ubuntu, you might not be using Gnome. This is the case for flavours such as: Kubuntu (KDE Plsama), Lubuntu (LXQt), Xubuntu (XFCE), and so on.

And if you have installed Skype using snap, then you will likely find that it will always ask you to login upon loading, even if you have it configured to automatically run at login.

The issue is that Skype installed via snap relies upon gnome-keyring, but fails to install it as a dependency.

Thankfully, one can install this dep. without bringing in the entirety of Gnome.

Open a terminal, and enter:

sudo apt install gnome-keyring

Restart (or start) Skype and login.

The application should communicate with the gnome-keyring service and securely store your login details.

Quit Skype and reload it. You should find that you are not asked for your login details again.

Embiggen .desktop loaded applications on Ubuntu

I keep forgetting the steps required for this, so thought I should write them up in one easy to remember blog post for myself.

My desktop set-up consists of 2 x 1080 and 1 x 4k display. Making sure that applications are readable is a bit of a farce.

But as long as I ensure that certain applications only ever appear on the correct monitor, means that I can alter the launcher to set the correct DPI scaling.

Case in point is the “thunderbird.desktop” launcher. I only ever use it on the 4k display (central monitor), so I can alter the launcher to pre-set the scaling to two times normal. Making it readable without squinting (I’m nearly 40 you know).

Using “locate thunderbird.desktop” we find that it’s stored at “/usr/share/applications/thunderbird.desktop”. So raised privileges will be needed to edit it.

“sudo nano -w /usr/share/applications/thunderbird.desktop”

Using “ctrl+\” to replace text, search for “Exec=thunderbird” and replace it with “Exec=env GDK_SCALE=2 thunderbird”. Use “ctrl+x” to save and exit the editor.

Now when the Thunderbird launcher icon is clicked, the application will be rendered at twice the normal size. Making the working day a lot less squinty.

apt-upgrade

I used to use a 2 command 1 liner to update my system:

sudo apt-get update && sudo apt-get dist-upgrade

That was easy enough to type out now and then. But over time it grew to include removing and cleaning downloaded packages as well.

Then there’s the matter of knowing if an update requires a system restart.

The lazy me put it all into one bash script and made it globally accessible and executable:

#!/bin/bash
apt update && apt full-upgrade && apt-get autoremove && apt-get autoclean
if [ -f /var/run/reboot-required ]; then echo && cat /var/run/reboot-required; fi

Placed it in /usr/local/bin/apt-upgrade  and made it executable with sudo chmod +x /usr/local/bin/apt-upgrade .

Now I can run sudo apt-upgrade on all of my servers and it’ll update things as well as letting me know if a reboot is required.

Unable to install sass gem on CentOS 6.9 with Ruby 2.4

Something changed recently, preventing a VM from fully provisioning. Tracking it down was a bit of a PiTA.

OS: CentOS 6.9
Ruby: 2.4 – installed from source with the gearlingguy.ruby ansible role
Gems to be installed: sass

$ sudo gem install sass
Fetching: rb-fsevent-0.10.2.gem (100%)
Successfully installed rb-fsevent-0.10.2
Fetching: ffi-1.9.21.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing sass:
    ERROR: Failed to build gem native extension.
    current directory: /usr/local/lib/ruby/gems/2.4.0/gems/ffi-1.9.21/ext/ffi_c
/usr/local/bin/ruby -r ./siteconf20180222-18730-x7wu2n.rb extconf.rb
checking for ffi.h... no
checking for ffi.h in /usr/local/include,/usr/include/ffi... no
checking for shlwapi.h... no
checking for rb_thread_blocking_region()... no
checking for rb_thread_call_with_gvl()... yes
checking for rb_thread_call_without_gvl()... yes
creating extconf.h
creating Makefile
current directory: /usr/local/lib/ruby/gems/2.4.0/gems/ffi-1.9.21/ext/ffi_c
make "DESTDIR=" clean
current directory: /usr/local/lib/ruby/gems/2.4.0/gems/ffi-1.9.21/ext/ffi_c
make "DESTDIR="
Running autoreconf for libffi
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal --force -I m4
configure.ac:3: error: Autoconf version 2.68 or higher is required
configure.ac:3: the top level
autom4te: /usr/bin/m4 failed with exit status: 63
aclocal: autom4te failed with exit status: 63
autoreconf: aclocal failed with exit status: 63
make: *** ["/usr/local/lib/ruby/gems/2.4.0/gems/ffi-1.9.21/ext/ffi_c/libffi-x86_64-linux"/.libs/libffi_convenience.a] Error 63
make failed, exit code 2
Gem files will remain installed in /usr/local/lib/ruby/gems/2.4.0/gems/ffi-1.9.21 for inspection.
Results logged to /usr/local/lib/ruby/gems/2.4.0/extensions/x86_64-linux/2.4.0/ffi-1.9.21/gem_make.out

The issue is with the ffi ruby gem.

Looking at the releases in github, a recent release updated the required version of autoconf installed on the system. Fine for modern systems, not so much for CentOS 6.9.

The solution is to install the ffi ruby gem with the version prior to this recent change:

$ gem install ffi -v 1.9.18

This then allows sass to be installed without complaint!

Setting up an On-Premise instance of Amon

NewRelic no longer offers server monitoring for free accounts, so what are the alternatives when you’re on a skin-flint budget?

There are lots, but I’m not going to review any of them. Instead, I’ve been tasked with getting Amon running on a DigitalOcean droplet so that it might be appraised.

Amon can either be used as a SAAS, hosted by Amon themselves. Or it can be run “On-Premise” by cloning the git repo to your own server.

The On-Premise instructions didn’t work for me as-is on a fresh Ubuntu 16.04 server. So I present to you here the result of getting it going!

Assumptions:

  1. You know what you’re doing with Linux on a server.
  2. You can create your own VPS, or have dedicated hardware, that will only be used for server monitoring.
  3. MongoDB is installed from Mongo’s repo, not Ubuntu’s.
  4. Let’s Encrypt is used for the SSL certificate.
  5. The FQDN used for accessing the Amon instance matches the server’s full hostname (easy enough to change by altering FULL_HOSTNAME).
  6. Postfix is used on localhost as the MTA (alter the content of /etc/opt/amon/amon.yml if that’s not to be the case).

The following took the instructions of https://docs.amon.cx/onpremise/ and then extended/tweaked them to create a fully working server.

So the initial script I wrote turned out better suited to being a collection of scripts. And to keep them together, I’ve created a new GitHub repo to house them.

If you find it useful, great! If you would like to help make the installation provisioning system better, PRs are very welcome 🙂

https://github.com/bigcalm/amon-server

Vagrant: sudo access and the hostsupdater plugin

Bringing up a vagrant machine is as easy as `vagrant up`.

If you’re a web developer, it would be nice if it were to add the private network IP address to `/etc/hosts` of the host machine. Thus giving you instant access to http://my-awesome-site.dev/

This doesn’t happen by default, but it is possible with the use of a plugin. The one I like to use is `vagrant-hostsupdater`.

Install thus:

vagrant plugin install vagrant-hostsupdater

When you bring up the vagrant machine, it will now automatically add the VM’s name to `/etc/hosts`.

As `/etc/hosts` is owned by `root` (and I hope you aren’t running everything as `root`), you have to provide `sudo` access to edit `/etc/hosts`.

Either you manually enter your `sudo` password every time you run `vagrant up`, or you can add some rules to `sudoers`.

This will work on Ubuntu type systems. Paths to `sh` and `sed` may be different on your own system.

Copy/paste the following into `/etc/sudoers.d/vagrant` and `chmod` the file to `0440`

# vagrant-hostsupdater plugin
Cmnd_Alias VAGRANT_HOSTS_ADD = /bin/sh -c echo "*" >> /etc/hosts
Cmnd_Alias VAGRANT_HOSTS_REMOVE = /bin/sed -i -e /*/ d /etc/hosts
%sudo ALL=(root) NOPASSWD: VAGRANT_HOSTS_ADD, VAGRANT_HOSTS_REMOVE

A similar system can be used if you want to make use of `nfs` for the file sharing with the VM.

Again, this works for Ubuntu systems, you mileage may vary.

Copy/paste the following into `/etc/sudoers.d/vagrant` and `chmod` the file to `0440`

# nfs mounting in vagrant
Cmnd_Alias VAGRANT_EXPORTS_ADD = /usr/bin/tee -a /etc/exports
Cmnd_Alias VAGRANT_EXPORTS_COPY = /bin/cp /tmp/exports /etc/exports
Cmnd_Alias VAGRANT_NFSD_CHECK = /etc/init.d/nfs-kernel-server status
Cmnd_Alias VAGRANT_NFSD_START = /etc/init.d/nfs-kernel-server start
Cmnd_Alias VAGRANT_NFSD_APPLY = /usr/sbin/exportfs -ar
Cmnd_Alias VAGRANT_EXPORTS_REMOVE = /bin/sed -r -e * d -ibak /tmp/exports
%sudo ALL=(root) NOPASSWD: VAGRANT_EXPORTS_ADD, VAGRANT_NFSD_CHECK, VAGRANT_NFSD_START, VAGRANT_NFSD_APPLY, VAGRANT_EXPORTS_REMOVE, VAGRANT_EXPORTS_COPY

You will now be able to use `nfs` without having to enter your `sudo` password on each `vagrant up` and `vagrant halt`.
 

Multi-screen with Ubuntu Unity

This tweet has to have been the most popular thing I have ever said. At time of posting it has gained 80 retweets, 25 favourites and many replies/questions.

Work recently bought me a new workstation, so the 1st thing I always do is to dual boot with Ubuntu.

Some might consider me an edge case user. Though as a developer, I like a rather particular set-up. That is, 3 wide screen monitors with the central one rotated 90 degrees for my IDE.

This is something that Windows gets right without having to dig about installing things. While Linux distros have always struggled (in my experience).

Because my tweet gained quite a few questions, I thought it best to reply to them here for everybody to see.

@ankitvad asks what specs. I use for Ubuntu.
Titanium Rimless Glasses from Spex4Less.com
Couldn’t resist, sorry 🙂

Dell Alienware X51
CPU: i7
Memory: 8GB
Graphics card: nVidia GeForce GTX 660
Storage: 1TB HDD (Windows) 120GB SSD (Linux)
Mouse: Logictech M570 trackball
OSs: Window 7 SP1, Ubuntu 12.10 64bit
Monitors: 2 x 22″ Dell, 1 x 22″ LG

All 3 monitors are connected to the one graphics card. Two by DVI and one by HDMI.

As I said, this is a working system from a fresh install without updates being applied or any 3rd party packages installed. So the default graphics driver is doing quite well these days 🙂

The only downside to this is that the default graphics driver is dog slow and won’t let me play games on Steam 😉 The next step will be to get the nVidia binary driver working.

Chroot SFTP home dir

Example user ‘iain’

sudo mkdir -p /chroot/iain/home/iain
sudo useradd -M -d /home/iain iain
sudo passwd iain
sudo chwon iain: /chroot/iain/home/iain

sudo nano -w /etc/ssh/sshd_config
# At the end of the file, add:

Match User paypoint
    ChrootDirectory /chroot/iain
    AllowTCPForwarding no
    X11Forwarding no
    ForceCommand internal-sftp

sudo /etc/init.d/ssh restart

Ubuntu 12.04 LTS on Bytemark VM

If, like me, you can’t wait for Ubuntu 12.04.1 to be released, you can force an upgrade of your favourite OS OS.

sudo apt-get update;
sudo do-release-upgrade -d

If you are going from the previous LTS 10.04, then the -d is important. Otherwise there would be no upgrade to offer.

The upgrade process should go smoothly enough. Except for when it comes to the kernel.

Bytemark VM’s make use of kernels that sit outside of the VM itself.

I didn’t realise this until I tried to fix syslog doing this:

Jun 26 10:30:01 banana kernel: Cannot read proc file system: 1 - Operation not permitted.
Jun 26 10:31:02 banana kernel: last message repeated 1745888 times
Jun 26 10:32:03 banana kernel: last message repeated 1722636 times
Jun 26 10:33:04 banana kernel: last message repeated 1621724 times
Jun 26 10:34:05 banana kernel: last message repeated 1761707 times

Even if you update grub, it’ll be ignored. Instead, follow the instructions here: http://www.bytemark.co.uk/support/technical_documents/kernelchange?tags=VirtualMachine

At the time of writing, I chose 3.2.0-kvm-i386-20110111 as it’s fairly close to the kernel being used by other Ubuntu 12.04 machines I have.

Your mileage may vary, but I hope this helps somebody else with the same trouble.

PPTP tunnels and if-up.d

Current project requires a couple of VPN tunnels to be set up. An IPsec and a PPTP.
The IPsec will wait for another day, the PPTP is set up and ready to go.
One thing that wasn’t quite right with the tunnel though, is the static route created by PPTP missed out a large chunk of the server’s network.

Starting the tunnel sets up the routing rule of 192.168.100.111 to be sent to the tunnel.

This meant that if I wanted to get to 100.10, it wasn’t being sent.

The way around this was to add a new route: route add -host 192.168.100.10 dev ppp0

Works great from the CLI, nothing happens when added to /etc/network/interfaces or /etc/network/if-up.d/foobar.

Found out (trial and error) that it was trying to add the route as soon as the tunnel was created. This doesn’t work as the tunnel takes a few seconds to wake up.

Work around was to add a ‘sleep 5’ to /etc/network/if-up.d/foobar before the route command line.

Creating race conditions isn’t nice, but it works 🙁