In Ubuntu I'm trying to run the geany editor on my local X display via the command:

 autossh -o StrictHostKeyChecking=false -XCg me@otherDYNDNShost geany &

Trouble is, after the first disconnect & auto re-connect, I have to fg that process to make the (new) geany responsive again, in my local X windows session. Which means that disown from the terminal caused it to get lost into a frozen sleeping state altogether, eventually.

How can I run this truly detached and independent of any terminal/tty?

Appending <&- to the command to cut off STDIN didn't seem to matter either.

  • 2
    Is it OK after the first disconnect, i.e. on subsequent reconnects will this problem happen again, or not? In the latter case detaching won't really help, maybe tmux or even xpra could help you a lot more here. Also the manual for autossh mentions -f did you try that? – Max Jan 5 '13 at 12:40
  • tmux/screen may indeed be viable; xpra proved too resource intensive on my lean 1-2GB PCs in the past (behind the scenes X server). In reality before having this problem I was trying to avoid using an ssh layer altogether, just sticking to classic xhost + over port 6000 (i.e. DISPLAY=otherDYNDNShost:0 geany &) but could still not figure out how to re-enable that network port in Ubuntu's X server, not even with DisallowTCP=false in /etc/gdm/custom.conf as researched elsewhere. – Marcos Jan 5 '13 at 18:50

Try using something like this with certificate authentication. It also provides dynamic proxy access to remote resources. It is my go-to way of doing remote IT Support with Linux and ssh. The ports I used are arbitrary...

autossh -M 18080 -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" -D 8080 root@server -p 22

It will keep you connected to the same remote session if you use tmux called on the remote in the "~/.profiles" file like this. You can name sessions to be more specific if needed...

tmux attach

You will need to create a "~/.tmux.conf" file with this inside or tmux will nest sessions which is very messy...

new-session -n $HOST

I use it everyday with Debian based systems and with cygwin. For a deeper understanding try using Google for the above detail. You can configure tmux to start one or more programs as well. I have not tested this with auto starting X programs though.

  • Yes, I've been using tmux to get netbeans running in a detached but stable way (and minus all its buggy log noise on some terminal). – Marcos Mar 3 '15 at 21:38

Try adding -f to autossh. Description of -f from ssh man page:

Requests ssh to go to background just before command execution. This is useful if ssh is going to ask for passwords or passphrases, but the user wants it in the background. This implies -n. The recommended way to start X11 programs at a remote site is with something like ssh -f host xterm.

If it won't work, try using daemon (http://www.libslack.org/daemon/). In Debian and derivatives package is named daemon. Example:

daemon autossh -o StrictHostKeyChecking=false -XCg me@otherDYNDNShost geany
  • Silly me, I tried -f right after posting and that worked, but felt bad about answering myself so fast. Thanks. However what's really annoying (and probably a different question) are its frequent disconnects & restarts, whilst another interactive ssh session seems way more tolerant of network hiccups and stays connected to one session. – Marcos Jan 5 '13 at 18:38

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.