Skip to content

Commit 4aceb6d

Browse files
committed
New post (terminal multiplexing and ssh), switch to using gists for embedded code.
1 parent 69ad8ae commit 4aceb6d

3 files changed

+21
-44
lines changed

_posts/2009-12-13-kerberos-and-ksu.html

+1-39
Original file line numberDiff line numberDiff line change
@@ -15,42 +15,4 @@
1515

1616
<p>So, I fixed both of those a while back, with a really ugly shell script. Just in case anyone else might find it handy, here it is:</p>
1717

18-
{% highlight bash linenos=table anchorlinenos=True lineanchors=ksu %}
19-
#!/bin/sh
20-
21-
# Replacement for raw "ksu" in kerberized environments;
22-
# behaves more like "su -", and retains xauth data.
23-
24-
if [ $# -lt 1 ]
25-
then
26-
echo "Usage: `basename $0` <target user> [ <command> [ <arg> ] ... ]"
27-
exit 2
28-
fi
29-
30-
TARGET_USER="$1"
31-
shift
32-
33-
# be a basic login shell if no command is specified.
34-
if [ -z "$*" ]
35-
then
36-
TARGET_CMD='-l'
37-
else
38-
TARGET_CMD="-c '$*'"
39-
fi
40-
41-
# FD 4 becomes stdin
42-
exec 4>&0
43-
44-
xauth list | sed -e 's/^/add /' | {
45-
# FD 3 becomes xauth output
46-
# FD 0 becomes stdin again
47-
# FD 4 is closed
48-
exec 3>&0 0>&4 4>&-
49-
50-
exec /usr/bin/env -u PATH -u LD_LIBRARY_PATH \
51-
/usr/krb5/bin/ksu "${TARGET_USER}" -e /bin/bash -l -c "
52-
xauth -q <&3
53-
cd
54-
exec /usr/bin/env DISPLAY='${DISPLAY}' "'"$SHELL"'" ${TARGET_CMD} 3>&-"
55-
}
56-
{% endhighlight %}
18+
<script src="https://gist.github.com/906849.js"> </script>

_posts/2010-09-17-bash-history.html

+1-5
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@
1010
---
1111
<p>A quick random Linux administration tip: add the following three lines to <kbd>root</kbd>'s <kbd>.bashrc</kbd>:</p>
1212

13-
{% highlight bash linenos=table anchorlinenos=True lineanchors=bashhist %}
14-
[ ! -d $HOME/.history ] && mkdir $HOME/.history
15-
set -- `/usr/bin/who -m`
16-
HISTFILE="$HOME/.history/`/bin/date +%Y-%m-%d.%T`.`/bin/hostname -s`.$$.$1"
17-
{% endhighlight %}
13+
<script src="https://gist.github.com/906847.js"> </script>
1814

1915
<p>Once you do, future login sessions as root will be saved in a directory named <kbd>.history</kbd> in <kbd>root</kbd>'s home directory, in the pattern:</p>
2016

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
layout: post
3+
title: "Terminal multiplexing and SSH"
4+
date: 2012-02-15 10:30:00
5+
categories:
6+
- linux
7+
- bash
8+
- shell
9+
- screen
10+
- tmux
11+
- ssh
12+
---
13+
<p>Tools like <a href="http://tmux.sourceforge.net/">tmux</a> and <a href="http://www.gnu.org/software/screen/">screen</a> are fantastic for doing work on remote systems: you can open up multiple sessions, fire off jobs, disconnect, and come back later, and things are still as you left them. However, if you use <a href="https://en.wikipedia.org/wiki/Ssh-agent">ssh-agent</a> for credential forwarding, you've probably noticed a downside: after disconnecting and reconnecting, the environment variables that ssh and friends use to figure out how to talk to ssh-agent are now wrong</p>
14+
15+
<p>There's a million different ways to solve this; here's my take on it:</p>
16+
17+
<script src="https://gist.github.com/1837945.js"></script>
18+
19+
<p>Adding this to your <kbd>.bash_profile</kbd> (or <kbd>.bashrc</kbd>, depending on your local setup) will add aliases for both <kbd>tmux</kbd> and <kbd>screen</kbd>, which will save the four SSH-related environment variables you'll want to override inside of your terminal multiplexor to a file in your home directory. It also adds aliases for <kbd>ssh</kbd>, <kbd>scp</kbd>, and <kbd>sftp</kbd>, which forces the saved variables to be loaded prior to execution.</p>

0 commit comments

Comments
 (0)