Every time I start tmux or split tmux, new instance of ssh-agent is started ("Agent pid XXXX" appears on the top), which is quite annoying because I have to type the key password every time I want to use it. Not to mention the number of ssh-agents at the end of the day.

I'm using Arch Linux with KDE and my $SHELL is zshell.

ssh-agent starts automatically on system boot, but I can't figure out who starts it - it's not in the .zshrc or .bash_profile, I've tried to grep for 'ssh-agent' in the ~but found nothing.

  • Does your .zshrc or .profile source any files in /etc? – Barmar Jan 20 '15 at 20:32
  • No, it doesn't. – nacholibre Jan 20 '15 at 20:36

By default, tmux spawns a login shell for all new windows. This would then source your ~/.zprofile or wherever your start your ssh-agent.

As man tmux makes clear, you can avoid this behaviour by explicitly setting a default command in your ~/.tmux.conf:

default-command shell-command
Set the command used for new windows (if not specified when the window is created) to shell-command, which may be any sh(1) command. The default is an empty string, which instructs tmux to create a login shell using the value of the default-shell option.

So, to prevent every new window being spawned as a login shell, add the following line to your config file:

set -g default-command /bin/zsh
  • I should have read the man page, thank you, it works :) – nacholibre Jan 21 '15 at 8:23
  • @nacholibre I thought you said none of your scripts in ~ ran ssh-agent. Did you miss .zprofile? – Barmar Jan 21 '15 at 17:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.