Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
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
up vote 0 down vote accepted

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.

share|improve this answer
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
share|improve this answer
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 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.