Da Kereoz Blog

To content | To menu | To search

Thursday 29 April 2010

Multiplexing ssh connections in one tunnel

Say you run a script with multiple ssh accesses to the same machine. You don't want to store the public key of the local machine on the server for security reasons, but you don't want to type the password every time a connection is made.

Adding those lines to ~/.ssh/config will do the trick

Host *

  ControlMaster auto
  ControlPath ~/.ssh/master-%r@%h:%p

See man ssh_config (5) for more details.

Sunday 26 April 2009

Unison or how to keep your data synchronized

Unison is an opensource file-synchronization tool for Unix and Windows written in CAML. Unlike rsync, it is able to propagate changes in both directions when synchronizing between two machines. I use it to keep my two laptops and my Desktop synchronized. Unison works both locally and remotely. SSH can be used to securely synchronize from anywhere to anywhere.

SSH options can be passed using the -sshargs option, eg:

unison folder1 ssh://machine/folder2 -sshargs '-port 2222'

Symlinks can be followed, and it makes things even easier : you can simply create a 'sync' folder in your home directory, containing symlinks to the data you want to keep in sync. I like to use it for config files such as .vimrc, .emacs.

Vim stuff

Hello world =) Let's start this blog with a short talk about vim. Even though Vim is one of the most powerful text editors ever, it is often underestimated by those who don't use it. The thing is that it takes times to get used to it. It is highly customizable, and scriptable. It even has a native Ruby support.

Some cool tips

  • I recently discovered the BufExplorer plugin. :BufExplorer show a list of buffers, allows to jump between buffers, to delete them etc.. like emac's C-x b so why not adding a key mapping like this ::nmap <C-x>b :BufExplorer <CR>
  • Substituting a string with another one in all opened buffer and save changes can be done with ":bufdo /string | :up". It can be generalized to any other operation. Very useful for core refactoring
  • The current buffer is represented by % in vim commands. For example, :ruby % will execute the current buffer as ruby code.
  • In visual mode, you can execute commands as well with ":!" and get the output of the command. It allows to evaluate code on the fly.

My vimrc is available through http://kereoz.org/.vimrc