Saturday, March 6, 2010

ssh tunneling (port forwarding)

The past two places I've worked at have had a single computer that would accept outside ssh communication. However, other computers in the network also had useful things on them but could only be reached from inside the network. How to connect to these other computers directly?

ssh port forwarding allows you to open up an ssh session between you and your gateway computer. Then, you can use that port to interact with the other computers in the network. Here is an example of how to do this:

Open a terminal and type in something like this:
ssh -L<unused_port#>:<final_destination>:22 <gateway_computer>
ssh -L22000:internalserver.super.duper.com:22 gateway.super.duper.com # e.g.
# you might want to add the -N and -C flags:
ssh -N -C ...
# -N Do not execute a remote command (useful for forwarding ports)
# -C compress (for slow network connections only)

Then, open another terminal and you can interact with the internal server as you normally would, just by interacting with your localhost through the specified port:
# log in to the internal server
ssh -p 22000 localhost
# scp stuff from the internal server
scp -P 22000 localhost:~/somefile.txt ./ # copy files from the internal server to local
# mount a folder from the internal server locally using sshfs
sshfs -p 22000 localhost:/home/<user>/<internal_dir> /home/<user>/mnt -o follow_symlinks


Yes that is localhost. You are connecting to port 22000 on the localhost and that is being tunneled via the gateway computer to the internal server!

This works but isn't the absolute slickest setup. Anyone know the equivalent commands for .ssh/config files?

This site has some alternative methods for mounting across ssh.

Thursday, March 4, 2010

Fonts in rumai (wmii)

How do you know what fonts you can use in rumai or wmii?
xlsfonts will list all the fonts in the format that wmii expects:

xlsfonts > available_fonts.txt

You can use the '*' symbol to generalize. Here are some that work ok. Some are quite ugly, others OK:

-*-fixed-medium-r-*-*-18-*-*-*-*-*-*-*
-*-fixed-bold-r-*-*-12-*-*-*-*-*-*-*
-*-fixed-medium-r-*-*-12-*-*-*-*-*-*-*
lucidasans-bold-12
-adobe-helvetica-medium-r-*-*-12
-adobe-helvetica-bold-r-*-*-12
-adobe-palatino-bold-r-*-*-14
-*-lucida-bold-r-*-*-12
-*-dejavu sans mono-medium-r-*-*-14
-*-dejavu sans mono-medium-r-*-*-14

Tuesday, March 2, 2010

wmii (rumai) with gnome in Ubuntu 9.10 & 10.04

NOTE: modified from here

This is a step by step to install rumai as the windows manager in gnome.

  1. install necessary packages
  2. 
    sudo apt-get install dwm-tools # for menus
    sudo apt-get install libixp libx11-dev  # for the install itself (necessary??)
    On Lucid Lynx I needed to install these two packages also:
    sudo apt-get install 9base libxft2-dev   # plan 9 file system (need on 10.04)
  3. Install a good build
  4. The Ubuntu wmii packages (karmic? and jaunty?) and even the current repo can be buggy. Download a solid build (hg2474) here or here. Unpack it, go into the src directory and sudo make install.
  5. modify some gnome settings
  6. 
    gconftool-2 -s /apps/nautilus/preferences/show_desktop --type bool false
    gconftool-2 -s /desktop/gnome/background/draw_background --type bool false
    ## Tell gnome to use wmii as the window manager
    gconftool-2 -s /desktop/gnome/session/required_components/windowmanager wmii --type string
  7. have wmii fire up at login
  8. System -> Preferences -> Startup Applications Add an entry for /usr/bin/wmii
  9. get rumai
  10. make sure you have ruby and rubygems. Works great with ruby 1.9. (I'm using 1.9.1)
    gem install rumai
    Also make sure your rubygems are executable by adding something like this to your .bashrc:
    export PATH="$PATH:$HOME/.gem/ruby/`ruby -e 'print RUBY_VERSION'`/bin"
  11. grab a rumai config wmiirc
  12. To make it easy for beginners, my master branch work's out of the box:
    git clone git://github.com/jtprince/wmiirc.git ~/.wmii
    For more advanced possibilities, you'll want to start with sunaku's and then branch, etc.:
    git clone git://github.com/sunaku/wmiirc.git ~/.wmii
    Now make a soft link to the file this wmii will be looking in:
    ln -s ~/.wmii ~/.wmii-hg
    Now logout and back in and it should work. This is pretty stable and works pretty well. If wmii crashes, restart in a terminal or from the panel (add a "run application") with the command "wmii" or "killall wmii && wmii".