Wednesday, September 23, 2009

Mandating key-based logins with sshd

This page provides a pretty good summary of creating a public/private key pair on the client and adding the public key to the server's authorized_keys file.

On the server side, edit /etc/ssh/sshd_config and add the directive PasswordAuthentication no and then restart sshd with sudo /etc/init.d/ssh restart Anyone that tries to log in to your server without a public key in the server's authorized_keys file will now not even be given the chance to enter a password.

sshd_config manpage

Monday, September 21, 2009


Xmonad is a sweet window manager. So sweet, in fact, that I've decided to use it. Here's a quick reference, basically the manpage rearranged (mod = alt by default) ... (also, remember to change the session login to "Run Xclient script" so that other things, like xmodmap, can be run in .xsession):

=== Launch ===
mod-shift-q -- Quit xmonad
mod-q -- Restart xmonad (and reload config file)
mod-shift-return -- Launch terminal
mod-shift-c -- Close the focused window
mod-p -- Launch dmenu

=== Layout ===
mod-space -- Rotate through the available layout algorithms
mod-shift-space -- Reset the layouts on the current workspace to default

=== Focus ===
mod-tab -- Move focus to the next window
mod-shift-tab -- Move focus to the previous window
mod-j -- Move focus to the next window
mod-k -- Move focus to the previous window
mod-m -- Move focus to the master window

=== Swap ===
mod-return -- Swap the focused window and the master window
mod-shift-j -- Swap the focused window with the next window
mod-shift-k -- Swap the focused window with the previous window

=== Resize ===
mod-h -- Shrink the master area
mod-l -- Expand the master area

=== Master Area (the area on the left) ===
mod-comma -- Increment the number of windows in the master area
mod-period -- Deincrement the number of windows in the master area

=== Workspace ===
mod-[1..9] -- Switch to workspace N
mod-shift-[1..9] -- Move client to workspace N

=== Multiple Screens ===
mod-{w,e,r} -- Switch to physical/Xinerama screens 1, 2, or 3
mod-shift-{w,e,r} -- Move client to screen 1, 2, or 3

=== Mouse ===
mod-button1 -- Set the window to floating mode and move by dragging
mod-button2 -- Raise the window to the top of the stack
mod-button3 -- Set the window to floating mode and resize by dragging
mod-t -- Push window back into tiling

=== Setup ===
sudo apt-get install xmonad dwm xlockmore xclock htop

=== ? ===
mod-shift-p -- Launch gmrun
mod-n -- Resize viewed windows to the correct size
mod-b -- Toggle the status bar gap

Here are some other useful utilities to replace functionality that is present in, say, GNOME on the command line:
How to install Xmobar

First, install the necessary packages:
sudo apt-get install libghc6-http-dev libghc6-zlib-dev libx11-dev libxft-dev

I hadn't installed any packages with cabal before, so I needed to set up that as well. I found it necessary to do the standard download, untar, runhaskell Setup configure && runhaskell Setup build && sudo runhaskell Setup install for the following packages:
A cabal update initializes the package database and a cabal install xmobar grabs the package.

Put this in your xmonad.hs (changing the paths appropriately, of course):

import XMonad
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Util.Run(spawnPipe)
import System.IO

main = do
xmproc <- spawnPipe "/home/dannyc/.cabal/bin/xmobar /home/dannyc/.xmonad/xmobarrc"
xmonad $ defaultConfig {
layoutHook = avoidStruts $ layoutHook defaultConfig
, logHook = dynamicLogWithPP $ xmobarPP
{ ppOutput = hPutStrLn xmproc
, ppTitle = xmobarColor "green" "" . shorten 50
And put this in your xmobarrc:
Config { font = "-*-Fixed-Bold-R-Normal-*-13-*-*-*-*-*-*-*"
, bgColor = "black"
, fgColor = "grey"
, position = TopW L 90
, commands = [ Run Weather "EGPF" ["-t"," <tempF>F","-L","64","-H","77",
"--normal","green","--high","red","--low","lightblue"] 36000
, Run Cpu ["-L","3","-H","50","--normal","green","--high","red"] 10
, Run Memory ["-t","Mem: <usedratio> 10
, Run Swap [] 10
, Run Date "%a %b %_d %l:%M" "date" 10
, Run StdinReader
, sepChar = "%"
, alignSep = "}{"
, template = "%StdinReader% }{ %cpu% | %memory% * %swap% <fc=#ee9a00>date%<fc> | %EGPF%"

There, you now have a bare-bones xmobar install. I figured this out by loosely following the instructions here. I don't know any haskell (yet) and this is my first time messing with the xmonad config, so I don't guarantee at all that I am doing things the Right Way. If your xmonad keeps locking up because of this configuration, see the big bold comment in the link above which points to here.

  • customize xmobar
  • some kind of screen-like titleing for workspaces
  • better fonts?
  • picture background on startup (/transparent windows?)