crumbtrail

Oct 15 2009

GNU screen Wrapper for SSH Agent Forwarding

This problem is well-documented around the web, this is just my personal reminder. Others have crafted various solutions varying in complexity. I like this one for the simplicity and easy portability—I don’t remember who to credit for it, unfortunately.

Without getting too deeply into the gory details, if you connect to a remote shell and run GNU screen there, then detach the screen and come back to it in a later SSH session, environment variables that SSH agent forwarding requires to function will have changed and your screen session is none the wiser. This is rather annoying if you frequently connect to a gateway server and use screen to do work on other servers inside of it—your public key will not be forwarded to the internal servers on subsequent connections.

Enter wrapper script to save new SSH variables when you connect again and resume your screen session:

#!/bin/bash
# Wrapper script to set SSH env vars so agent forwarding works when
# resuming screen sessions. Place at ~/bin/screen and make sure
# your personal bin directory has priority in your PATH

for SSHVAR in SSH_CLIENT SSH_TTY SSH_AUTH_SOCK SSH_CONNECTION DISPLAY; do
    echo "export ${SSHVAR}=\"${!SSHVAR}\""
done > ~/.sshvars
/usr/bin/screen $*

Then, a simple alias for your .bashrc, to run once you’ve resumed screen:

# After reconnecting to a screen session, this restores env vars
# to allow agent forwarding to work again
alias fixssh='source ~/.sshvars'

Off you go to now to connect to those internal servers needing your forwarded key.

Oct 08 2009

Sanely Rebuild Corrupt Font Caches on OS X

For Leopard, at least:

# Clear user font caches
$ atsutil databases -removeUser

# And system cache
$ sudo atsutil databases -remove

# Restart the ATS server
$ atsutil server -shutdown
ATSServer shutdown
$ atsutil server -ping
ATSServer is running

# Check for filesystem activity (this is just generally cool)
$ sudo fs_usage | grep ATS
You might possibly still need to restart applications, log out and back in, or restart completely. Thanks to the fine people on this thread.

Jul 05 2009
The future is no more uncertain than the present.
— Walt Whitman
Dec 02 2008
I’m no good at those “guess how many jelly beans are in the jar” things though. Usually you just win the jar anyway, and who wants that many jelly beans?
Nov 06 2008

Gorefest

‘clean blood stain’ is probably one of those Web History moments where you want to make certain that you’re logged out of your Google account.

Oct 03 2008

Um... Arrrr!!

  • Ches
  • I've switched Facebook to Pirate speak and it's pretty awesome
  • Sophie
  • You win! That's the most inane thing I've heard so far today
Jun 23 2008

Get the Ruby mysql gem to build with MySQL installed from 64-bit binary installer:


sudo env ARCHFLAGS=”-Os -arch x86_64 -fno-common” \
gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
Courtesy of synth @ Chris Cruft » Blog Archive » Ruby, Rails and MySQL with Leopard 10.5.2 and XCode 3.0

Apr 04 2008
  • Sophie
  • Do you know what I would have to do to make $65 an hour?
  • Ches
  • does it involve a pole and acrylic shoes?
Mar 31 2008

Swap Control and Caps Lock in X.Org

In the keyboard section of xorg.conf:

Option "XkbOptions" "ctrl:swapcaps"

This will naturally effect all X users on a system, so you may want to look at alternatives if you’re not the only one using your system ;-)
Mar 13 2008

Bash Prompt

export PS1="\n\[\033[0;32m\]\w\[\033[0m\]\n[\u@\h]\$ "

Produces a prompt that looks something like this, with that initial newline giving some space from the output of the previous command:

~/src/lexblog/lexcode
[ches@porco]$ 
Page 1 of 2