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.

ssh'ing to my Ubuntu machine automatically attaches an existing screen session and detaching ends my ssh session


What I want is to be able to ssh to my Ubuntu machine without automatically attaching to the screen session on that machine. Or at least, I should be able to to detach from that screen session w/o ending my ssh session .. right? Doesn't seem to work.

This so that I can attempt to run firefox --display <whichever one is being forwarded to my ssh session>, so that I can debug a website that the remote Ubuntu machine is running (via localhost).

Best case scenario is that I could just remote-desktop to my Ubuntu machine. But it's not set up to allow remote-desktop, and I see no way to set it up remotely via shell/ssh. Also, it sounds like you need a static IP in order to remote desktop to an Ubuntu machine (so I keep reading).

share|improve this question
    
What ssh command are you connecting with? A default ssh into a machine shouldn't connect to a running screen session unless you specify it as the command parameter to ssh or have it in the login script... –  jmetz Aug 4 '12 at 20:59
    
via a vpn connection:ssh -X <hostname> –  jsplaine Aug 4 '12 at 21:39
    
So how do you automatically connect to a running screen session - is there a login script? –  jmetz Aug 4 '12 at 21:46
    
I don't see the word "screen" in /etc/login.defs anywhere and I should mention that byobu (a nice screen wrapper utility) is running on the remote machine. It must be doing something... Also note that it's a fairly recent install of Ubuntu. –  jsplaine Aug 4 '12 at 21:46

1 Answer 1

up vote 1 down vote accepted

Original Answer

It seems that your byobu installation has probably edited one of your login script files. You should search these, namely

  • ~/.bashrc
  • ~/.profile
  • Possibly the system-wide files too

for byobu or screen - you can use grep or just open up the file.

E.g. Open ~/.bashrc and search for byobu, namely something like

if [ $SSH_TTY ] && [ ! $WINDOW ]; then
    SCREENLIST=`screen -ls | grep 'Attached'`
    if [ $? -eq "0" ]; then
        echo -e "Screen is already running and attached:\n ${SCREENLIST}"
    else
        type -P byobu &>/dev/null && byobu -U -R || screen -U -R
    fi
fi

Comment out this section to restore normal ssh behaviour.

See here for more information about this automatic reattaching behaviour.

This Is What Worked (see comments below)

In ~/.profile, comment out _byobu_sourced=1 . /usr/bin/byobu-launch

And if you're trying to launch an X11 Firefox session, just ssh -X <hostname> firefox (you may need to add the -no-remote flag).

share|improve this answer
    
Hm .. not only is nothing like that in my .bashrc but the word screen appears nowhere on any file in my home directory. jsplaine@xxx:~$ grep -i screen ~/* jsplaine@xxx:~$ –  jsplaine Aug 4 '12 at 22:09
    
re-ran a search with find . -maxdepth 1 -type f|xargs grep -i screen -- found stuff in bash_history, ./.viminfo, and ./.xsession-errors.old only –  jsplaine Aug 4 '12 at 22:16
    
checked /usr/share/base-files/dot.bashrc, /etc/bash.bashrc, /home/jsplaine/.bashrc, and /usr/share/base-files/dot.bashrc. No mention of screen or byobu.. : / –  jsplaine Aug 4 '12 at 22:22
    
Even killing the screen session kicks me out of ssh, and ssh again begins a new screen session it seems. Meh whatever -- all I need to do is run an X11 browser OR remote-desktop. –  jsplaine Aug 4 '12 at 22:23
1  
done -- I'd vote up if I had the rep. Thank you very much. And if you're super bored, there's always this Setting up remote desktop via ssh? :D –  jsplaine Aug 4 '12 at 23:43

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.