1

So on Ubuntu, whenever I SSH to a machine, I get a prompt to unlock my private key and until I quit my OS session, I can SSH to as many machines as I want using key authentication and not having to enter anything. On Debian, I will get a prompt for a password every time I do anything. If I run "ssh-add", then I will then not have to enter a passphrase again whilst I keep using this same terminal window. If I open a new terminal, I will need to run the ssh-add again. Does anyone have any tips on Getting Debian 7.1 to copy the functionality that Ubuntu offers here?

1 Answer 1

2

The secret is that there is ssh-agent running on the background and Ubuntu saves settings for this process somewhere. So in order to make things go like that you need to a) start ssh-agent on the background and b) save PID of that process somewhere so that you can then source the value for PId for all subsequent shells.

When ssh-agent is started, it will output its PID and some other information you'd want to source later when spawning new shells. Something like the following in your ~/.bashrc might work:

setf="$HOME/.ssh_agent_settings"          # filename for storing PID etc.
[ -r $setf ] && . $setf > /dev/null 2>1   # source PID etc. if file exists
kill -0 $SSH_AGENT_PID > /dev/null 2>&1   # kill -0 will fail if process doesn't exist
[ "$?" -eq 0 ] && exit                    # kill returns 0 on success
ssh-agent > $setf                         # process doesn't exist, so we create one
. $setf > /dev/null 2>&1                  # source PID of the newly created process

This will start ssh-agent on the shell initialization, in case it's not running already, or just source ssh-agent PID and AUTH_SOCK variables from ~/.ssh_agent_settings.

You must log in to answer this question.

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