mkogg.py: Fix 'self.get_mp4_metadata(self, source)'
[blog.git] / posts / SSH.mdwn
1 [[!meta  title="Secure Shell"]]
2
3 If you want to get anything done on a remote host, you use [SSH][].
4
5 Password-less SSH
6 -----------------
7
8 Since I use SSH a lot, I've gone through the minimal effort required
9 to setup password-less SSH between the computers on which I have
10 accounts.  Note that you should only keep private keys on computers
11 that you trust (i.e. computers where you are the only admin).
12
13 I don't end up typing these commands very often, so I've created a set
14 of three simple scripts ([[ssh-key.sh]], [[ssh-remote.sh]], and
15 [[ssh-prime.sh]]), since `ssh-<TAB>` is easier to remember than the
16 commands themselves.  With the scripts in your path, run:
17
18     $ ssh-key.sh
19
20 to generate a SSH private/public keypair.  Then run:
21
22     $ ssh-remote.sh me@remote.edu
23
24 to configure your `remote.edu` account to allow passwordless logins
25 from your new key.  After each login, run:
26
27     $ ssh-prime.sh
28
29 and enter your passphrase to start the SSH agent, and tell your shell
30 about the agent with:
31
32     $ . /tmp/$(whoami)/.ssh/.ssh-agent-info-$(hostname)
33
34 I usually prime the SSH agent right after I log in (before running
35 [[screen]] or `startx`) to that new terminals come up knowing about
36 the agent.  You can also add something like:
37
38     SSH_INFO_FILE="/tmp/$(whoami)/.ssh/.ssh-agent-info-$(hostname)"
39     if [ -f "$SSH_INFO_FILE" ]; then
40         . "$SSH_INFO_FILE"
41     fi
42
43 to your `~/.bashrc` (or equivalent shell initialization file), after
44 which spawning shells will automatically pick up SSH agent
45 information.
46
47 Grabbing a ssh-agent by process ID
48 ----------------------------------
49
50 If you clobber your `ssh-agent` environment somehow (or you want to
51 “borrow” another user's agent to show them the security risks of
52 running an agent on a computer that they don't own),
53 [[ssh-agent-grab.sh]] will show you how to setup your environment:
54
55     $ ps -ef ssh-agent
56     ...
57     jdoe     11862     1  0 Nov18 ?        00:00:01 ssh-agent
58     ...
59     $ ssh-agent-grab.sh 4580
60     export SSH_AUTH_SOCK=/tmp/ssh-oTZLe11861/agent.11861
61     export SSH_AGENT_PID=11862
62     $ export SSH_AUTH_SOCK=/tmp/ssh-oTZLe11861/agent.11861
63     $ export SSH_AGENT_PID=11862
64     $ ssh jdoe@elsewhere
65
66 mxconns
67 -------
68
69 [[mxconns]] is a simple X monitor and proxy that I use to accept
70 remote X connections when running [[MPE]] on my [[cluster|Abax]].  The
71 `mxconns` post has more details if you're interested.
72
73 Credits
74 -------
75
76 This sort of thing is the subject of innumerable websites, but due to
77 the fluid nature of the web, they tend to disappear over time.  Thanks
78 to Ted Dustman (at the University of Utah in 2007) for his post (now
79 missing).  Still available related posts:
80
81 * [Kristina Wanous and company at Debian Clusters][DC]
82
83 [[!tag tags/linux]]
84
85 [SSH]: http://en.wikipedia.org/wiki/Secure_Shell
86 [DC]: http://debianclusters.cs.uni.edu/index.php/Password-less_SSH_for_Users