0

I want to link some passwordless SSH logins to some screen sessions, so that anytime a window is opened in the screen session the ssh-agent is inherited, but whenever I open a new window in screen, the ssh-agent reverts back to the main sessions settings.

This is what I'm attempting but it doesn't work:

Before I start the screen session, I run eval `ssh-agent`. This ensures that the main ssh-agent which is set via key-chain doesn't get passed on.

However when I run screen it reverts back to the main ssh-agent's settings, and even when I run eval `ssh-agent` again within that window, the settings don't carry on to the next window.

Is there some way to run an ssh-agent session that can be carried on to each new window within screen?

In sum, I think I need to select which ssh-agent I should use whenever I open a new terminal window. If I have a number of ssh-agent sessions running, is there a way to choose which one a newly opened terminal window, or even an existing terminal window should use?

1
  • At any time you should be able to set the environment to the current value for the ssh-agent socket, and have it apply to all newly created screen windows: Use shell command screen -X setenv SSH_AUTH_SOCK $SSH_AUTH_SOCK.
    – meuh
    Commented Aug 25, 2022 at 10:04

1 Answer 1

1

Screen version 4.09.00 seems pretty limited here, unless I missed something in the manual. There does not appear to be an update-environment like tmux has. CONTROL+a : lets you type in setenv BLAH foo to change the value the screen session holds and thereafter any new windows created. Maybe instead source in the changed agent settings via the shell . or source command, possibly via a little selector function of some sort, possibly also picking some default when your shell starts up?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .