I'm curious as to how you can go about starting software through an SSH tunnel, but keep the software running on the SSH server.

For example, I host a minecraft server for my brother and his friends. If something happens and I need to restart the minecraft software, while I can do it from any computer via Putty or the Terminal, that session of the minecraft software running will only stay alive if I keep the SSH tunnel up.

How can I start software and services using SSH without having the SSH Client host the software sessions?

closed as off topic by Sven, Chopper3, Dan, EEAA, Ward May 29 '12 at 3:05

Questions on Server Fault are expected to relate to server, networking, or related infrastructure administration within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here. If this question can be reworded to fit the rules in the help center, please edit the question.

  • This is a question about your hobby and therefore off-topic here. Anyway, read minecraftwiki.net/wiki/Tutorials/Setting_up_a_server – Sven May 28 '12 at 15:40
  • Thanks, but that link is actually off topic. I don't care about minecraft, I'm asking a general question about ssh. The minecraft example was just that...an example. – Kyle May 28 '12 at 15:50

In this example I will use svnserve as the daemon process that has to be started. So, assuming your SSH user-name is "kyle" and your server's host-name is "home.example.com", you can execute following:

ssh -f kyle@home.example.com "svnserve -d"

Sometimes user must force allocation of the pseudo-terminal, in that case use the -t flag:

ssh -t kyle@home.example.com "svnserve -d"

If your daemon process does not know how to "daemonise" itself, then you can send it to the background:

ssh -f kyle@home.example.com "/usr/local/bin/minecraft-server &"

Reading SSH manual page is highly recommended... ;) You could find this information yourself if you have spent 2min reading SSH client's manual page.

  • Thank you Dejan. I appreciate the answer and will make sure all future questions have more thorough research first. – Kyle May 28 '12 at 16:50

You should use screen or tmux.

screen start screen, then you can attach and detach the terminal at will ( ctrl + A , D ) to detach.

  • 2
    No. Running a server software from inside a screen session might be possible but you want to create a proper service out of it so it get actually started automatically if you need to restart the machine. – Sven May 28 '12 at 15:39
  • Writing a service is most of the time non trivial to do it right ( some servers do not correctly close all open files, do not write pid file, etc ). This also requires root access and not everybody has it. – Misc May 28 '12 at 15:44
  • 1
    Yes, this is a task for a professional sysadmin, not an amateur. Server Fault is for pros only. – Sven May 28 '12 at 15:46

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