Seamless ssh access

If you have access to multiple class accounts or vx/exam accounts, as part of your workflow, you may want to ssh into another account from the account you are currently at.

  1. Start ssh agent in your current login session. This can be achieved in your .xsession

  2. Add your private key to the agent using ssh-add. You can store multiple identities in the agent.

  3. Forward the agent - Either use “ssh -A” or add “ForwardAgent yes” to your ~/.ssh/config

~/startsshagent script

#!/bin/bash SSH_ENV=~/.ssh/environment.`hostname` 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} /usr/bin/ssh-add ~/.ssh/id_rsa < /dev/null } # Source SSH settings, if applicable if [ -f "${SSH_ENV}" ]; then echo "Found ${SSH_ENV}" . ${SSH_ENV} ps -ef | grep ${SSH_AGENT_PID} | grep 'ssh-agent' || { start_agent; } else start_agent; fi

~/.xsession script

. ~/startsshagent exec startxfce4

~/.ssh/config

Host * ForwardAgent yes ForwardX11 yes StrictHostKeyChecking no

Other Methods

  • In your .xsession,

exec ssh-agent startxfce4

  • In your xterm,

eval $(ssh-agent)