Log in

No account? Create an account
Tim's blog
technology, business, culture, and all the rest
GNU screen and SSH 
20th-Apr-2004 02:18 pm

Updated 13 Sep 04. Nevermind. phil_g's comment says it well. keychain is the way to go. I'll rewrite this when I have more time.

Some co-workers turned me on to GNU screen last year. It's a handy addition to my toolbox. It became most useful after I learned how to use it with SSH. The original URL that gave me the solution appears to be gone (a message in the now-defunct gnu-screen Yahoo group). So I thought I'd write this up and see how it fares when people google gnu screen ssh.

The solution I settled on is a nested invocation I learned from Jason White. I recommend you read my screenrc and my slave screenrc in another window and read along here for commentary. You run an "outer" screen session (the "slave" session) that in turn runs an "inner" (or "master") session. You use the regular escape sequence (Ctrl-A d) to detatch from the master, and you map Ctrl-^ to be the control key for the slave session. If you press Ctrl-^ while using screen this way, you'll see one process in the slave session. It's running ssh-agent. That's the key to using ssh with screen. The slave's only purpose is to run ssh-agent. The master runs as a child of that. Consequently, all shells in the master session are running under the ssh-agent. Just run ssh-add from any master shell, and then all shells have your ssh identity.

For more information about GNU screen, see GNU Screen: an introduction and beginner's tutorial or Power Sessions with Screen. For more information about SSH, see openssh.com.

6th-Jul-2004 08:57 am (UTC) - Nested Screens Not Necessary
You don't need to use nested screens to get this effect. I achieve it by the use of a simple wrapper script for screen. To attach to a screen session, I have a single script that I run; it loads the agent before starting screen. (I use keychain to ensure that only one agent instance is running, regardless of how many times I attach to screen.) See my attach-screen script for specific details.
6th-Jul-2004 10:10 am (UTC) - keychain
Thanks, phil_g. keychain looks like the solution I really want. I'll give it a try.
18th-Jan-2010 01:22 pm (UTC) - .
I use screen and SSH this way:

1- Log into the remote computer using SSH.
2- Run screen
3- Run the process I want
4- Detach
5- Quit SSH

The process keeps running and I can access it later with screen -r.
21st-Feb-2012 04:07 am (UTC)
rollieemuv wrote, "Если не секрет, дорого обошлось создание блога? Тоже хочется попробовать вести своё что-нибудь." But I banned him because his LiveJournal is juvenile.
This page was loaded Feb 19th 2019, 7:00 pm GMT.