Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

byobu cannot connect to ssh-agent socket well. actually I can make just one connection via ssh-agent but if I try to establish another ssh connection using the agent, it doesn't work. I've tried

setenv SSH_AUTH_SOCK `echo $SSH_AUTH_SOCK`

in ~/.byobu/profile but it didn't work as well.

share|improve this question

4 Answers 4

I'm not sure why people attempt to solve this at the terminal multiplexer configuration level. That's not a place for it, unless you want to have to do it again because you've switched to tmux, screen, etc.

Every time you open another window, your shell gets executed and reads its configuration files.

Sourcing this from your shell configuration file solves the problem for any shell that I use:

#!/bin/bash
SSH_AGENT_TYPE="ssh"
SSH_AGENT_INFO="${HOME}/.ssh-agent"

source_agent_info() {
  export SSH_AUTH_SOCK=''
  export SSH_AGENT_PID=''

  if [[ -f ${SSH_AGENT_INFO} ]]; then
    source ${SSH_AGENT_INFO}
  fi
}

agent_running() {
  source_agent_info
  proc_file="/proc/${SSH_AGENT_PID}/cmdline"
  if [[ "${SSH_AGENT_PID}" =~ ^[0-9]+$ ]] && \
     stat "${proc_file}" &> /dev/null && \
     grep ssh-agent "${proc_file}" &> /dev/null; then
    return 0
  else
    return 1
  fi
}

run_ssh_agent() {
  ssh-agent 2>&1 | grep -v echo > "${SSH_AGENT_INFO}"
  source_agent_info
}

if ! agent_running; then
  run_ssh_agent
fi
share|improve this answer

This issue is detailed in Bug #664059, and solved for byobu versions 3.7 and above.

Basically, there is an incorrect assumption that /var/run/screen/S-$USER/ will exist and be writable at the point at which the SSH socket needs to be set. So I moved the symlink to the SSH socket to $HOME/.byobu/.ssh-agent.

share|improve this answer
    
I have the same problem in byobu 5.17, there is a valid link from $HOME/.byobu/.ssh-agent to /tmp/ssh-... –  txwikinger Jul 18 '13 at 14:01
    
Ah well.. I killed all windows and exited byobu and after restart it worked –  txwikinger Jul 18 '13 at 14:24

There is a bug report #616899 which sounds similar to your problem. They suggest to download byobu v3.1 and manually install it.

share|improve this answer

I've been doing ssh-agent byobu all the environment variables gets passed easily.

share|improve this answer
    
I don't understand why I was down voted. It works and answers the question easily. I've been using this to connect to 10+ servers from anywhere. The complicated answer up there does not apply anymore. Oh well. –  Howard Tan May 21 at 23:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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