0

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?

2
  • 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, 2012 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, 2012 at 15:50

2 Answers 2

3

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 [email protected] "svnserve -d"

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

ssh -t [email protected] "svnserve -d"

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

ssh -f [email protected] "/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.

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

You should use screen or tmux.

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

3
  • 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, 2012 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, 2012 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, 2012 at 15:46

Not the answer you're looking for? Browse other questions tagged .