Use SSH config file to easely connect to servers via alias names

I don’t have a very good memory and always have problems remembering my servers names when connecting to them via SSH. I usually used this “solution”:

$ history | grep ssh

Yep… not very neat. A friend (follow him, you’ll learn lots of things!) told me I could use Control+Shift+R in the terminal and It was like “OMG! This is great!”. After pressing that key combination you can start typing a command and you’ll get matches to previous commands with that text, so all I had to do was type “ssh” and then press enter. Magic!

reverse-i-search

But today I found another way that involved using the ~/.ssh/config file. The first step is to create this file in the correct place and, most important, with the correct permissions:

$ touch ~/.ssh/config
$ chmod 600 ~/.ssh/config

Now lets suppose we usually connect to a server called vps1.hostingsolution.com with a user named myuser. We can add this to ~/.ssh/config:

Host vps1
  HostName vps1.hostingsolution.com
  User myuser

And here comes the cool part: now we can connect to this server with that user name by just typing this:

$ ssh vps1

That’s it. And of course you can add more and more configurations to it:

config

And if we also have enabled the connection using public/private keys we don’t even have to write a password.

This file is very heplful for other things too. For example you can make speed up SSH if you configure ControlMaster because it enables the sharing of multiple sessions over a single network connection.

Host *
  ControlMaster auto
  ControlPath ~/.ssh/ssh_mux_%h_%p_%r

If you get this error while connecting after configuring this it’s very likely because the ControlPath route does not exists or is write protected:

muxserver_listen bind(): No such file or directory

Ref: http://mattryall.net/blog/2008/06/ssh-favourite-hosts
https://twitter.com/nixcraft/status/570208662368575488

Enable hosting files outside /var/www in Apache2

I’m using Ubuntu and Mac OS X in my computer. I wanted both to share a partition to put all the things that could be duplicated in both systems: DropBox, downloads, music, etc. The websites I’m developing would be also there but I was getting 403 errors all the time. Anything outside /var/www won’t work. Finally I found out that there is a Directory configuration in /etc/apache2/apache2.conf that denies access to anything outside /var/www and /usr/share:

<Directory />
       Options FollowSymLinks
       AllowOverride None
       Require all denied
</Directory>

<Directory /usr/share>
        AllowOverride None
        Require all granted
</Directory>

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>

To fix this you can disable the first Directory block or even better add a new one with Require all granted in it for your speceific path:

<Directory /home/shared/www/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>

apache_logo

Byobu: the text-based window manager and terminal multiplexer

Byobu is a text-based window manager and terminal multiplexer. This video is a great overview and tutorial on what it can do:

Install in Ubuntu:

$ sudo apt-get install byobu

Install in Mac OS X with brew:

$ brew install byobu

Install in Mac OS X with macports:

$ sudo port install python27 gettext libnewt coreutils gsed
$ curl -L -O https://launchpad.net/byobu/trunk/5.91/+download/byobu_5.91.orig.tar.gz
$ tar xzpf byobu_5.91.orig.tar.gz
$ cd byobu-5.91
$ ./configure
$ make
$ sudo make install

byobu

Ref: http://randomfoo.net/2014/01/14/byobu-on-mac-w-macports

Generate a file with current Xorg server configuration

Run from a terminal this command:

$ sudo X :2 -configure

It’ll create a file in current users home folder called xorg.conf.new with all the configuration used at that moment by the Xorg server.

xorg_logo

Ref: http://ubuntuforums.org/showthread.php?t=1478310&p=9322591#post9322591

Changing rEFInd options

If you use rEFInd to boot multiple operating systems in a Mac you may want to change it’s options. For example the default 20 second timeout, in my opinion too long.

refind

Booting from Mac OS X you’ll have to mount the rEFInd partition. You can see which partition it is in with this command:

$ diskutil list | grep EFI
   1:                        EFI EFI                     209.7 MB   disk0s1

Now that we know it is in disk0s1 we mount it:

$ mkdir /Volumes/temp
$ diskutil mount -mountPoint /Volumes/temp /dev/disk0s1 

The main configuration file can be found in /Volumes/temp/EFI/refind/refind.conf. Here you can change for example the timeout or the deault menu selection (by default rEFInd remembers the last selected one):

timeout 5
default_selection 1

Once we change everything we want just unmout the partition:

$ diskutil unmount /dev/disk1s0