Subject: Re: console scrollback ?
To: None <>
From: Mike Parson <>
List: netbsd-users
Date: 12/08/2004 14:51:05
On Wed, Dec 08, 2004 at 12:34:09PM -0800, Ian Main wrote:
> Actually I've been trying to use ssh-agent with screen and it doesn't do 
> what I want.  I wonder if you have solved this?
> I run ssh-agent screen, fire up a few screens, do my ssh-add, and it 
> works it's magic while I'm connected to that session.  Soon as I 
> disconnect from screen and reconnect my ssh-agent isn't running anymore 
> (or at least ssh-add fails to connect to it).
> There a way around this?   What I really want is to have my key 
> permanently in screen :)

Small misunderstanding of how agents work. =)

Start your agent as early as possible in the process, I generally have
it managing my windowmanager(s).

When you connect to the host you're running screen on, if it's not the
localhost, either have agent forwarding turned on, or start a new agent
with a shell or something as the sub-process, ssh-add, then grab the ssh
variables out of your environment:

$ ssh-agent bash
$ ssh-add
Enter passphrase for /home/mparson/.ssh/id_dsa: 
Identity added: /home/mparson/.ssh/id_dsa (/home/mparson/.ssh/id_dsa)
$ env | grep SSH

Then re-attach to your screen session:

$ screen -r

Now, you'll have to add those variables to your screen:

C-A : setenv SSH_AGENT_PID <return> 6486 <return>
C-A : setenv SSH_AUTH_SOCK <return> /tmp/ssh-xxMt6484/agent.6484 <return>

Now screen knows about the agent stuff, at least till your agent changes
(login from a different host, xsession dies and you have to re-attach,

I've not figured out a good way to automate this yet.

Michael Parson