back to listing index

SSH agent forwarding and screen

[web search]
Original source (
Tags: screen ssh-agent-forwarding
Clipped on: 2017-06-19

Image (Asset 1/14) alt= btw: both boxen are FreeBSD. The FBSD core committers change some of the ssh defaults to enhance security which might explain the differences if Linux exhibits differently?

Image (Asset 2/14) alt= I use following in my .bashrc

export SSH_AUTH_SOCK=$(find /tmp -maxdepth 2 -type s -name "agent*" -user $USER -printf '%T@ %p\n' 2>/dev/null |sort -n|tail -1|cut -d' ' -f2)

And then i just reread my .bashrc in screen windows to apply working ssh socket.

Image (Asset 3/14) alt= start screen
ssh to computer 2 (confirm can ssh to computer 3 via forwarding; exit back to computer 2)
log off computer 1
ssh to computer 1
re-attach screen

expect to be on computer 2

ssh to computer 3 (fails)

Will this method fair better?

Image (Asset 4/14) alt= found here:

function start_agent {
  echo "Initialising new SSH agent..."
  /usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
  echo Succeeded
  chmod 600 "${SSH_ENV}"
  . "${SSH_ENV}" > /dev/null

if [ -f "${SSH_ENV}" ]; then
  . "${SSH_ENV}" > /dev/null
  ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {

atm idk how to pair this with tmux, someone?

Or adopt this awesomeness:

Image (Asset 5/14) alt=