Jump to content

SSH Sessions with Ubuntu Server

Furball159.
Go to solution Solved by Furball159.,

Thankyou to all of you who looked into this to help, I ended up using Crafty and getting it setup was a small chore for me, but it works perfectly now

Hey guys.

This isn't really a issue as of the moment as i don't have the hardware ready for this to be a issue, im just trying to work out if i connect to a SSH session with ubuntu server, then start somthing like a minecraft server and then disconnect, will i be able to recconect to the same console again as in, can i ssh back into the server and see the mc server outputs and issues commands or will it dump me back into a normal terminal. I'm trying to set up a mini server network but it is proving to be slightly challanging.

Any form of help is gravely appricated.

Link to comment
Share on other sites

Link to post
Share on other sites

Not directly, by default if you close the connection anything in the terminal would be closed.

There are tools like screen or tmux you can use to create persistent sessions that run in the background and can resume.

 

But for something like a minecraft server you'd set it up as a service.

F@H
Desktop: i9-13900K, ASUS Z790-E, 64GB DDR5-6000 CL36, RTX3080, 2TB MP600 Pro XT, 2TB SX8200Pro, 2x16TB Ironwolf RAID0, Corsair HX1200, Antec Vortex 360 AIO, Thermaltake Versa H25 TG, Samsung 4K curved 49" TV, 23" secondary, Mountain Everest Max

Mobile SFF rig: i9-9900K, Noctua NH-L9i, Asrock Z390 Phantom ITX-AC, 32GB, GTX1070, 2x1TB SX8200Pro RAID0, 2x5TB 2.5" HDD RAID0, Athena 500W Flex (Noctua fan), Custom 4.7l 3D printed case

 

Asus Zenbook UM325UA, Ryzen 7 5700u, 16GB, 1TB, OLED

 

GPD Win 2

Link to comment
Share on other sites

Link to post
Share on other sites

It depends on how you start the server but from what I remember doing this a while back if you exit the default session then it kills the server. The way around this is with screen. You create a screen session, start the MC server, and then disconnect from the screen session and then you can resume and disconnect, just be careful not to close the screen session 🙂

 

If it's a service then it's much easier to start and stop and whatnot.

Current Network Layout:

Current Build Log/PC:

Prior Build Log/PC:

Link to comment
Share on other sites

Link to post
Share on other sites

Thanks to both of you for that, any reccomendations on how to set up mc as a service and how i would be able to acsess its internal console via ssh and physically being there???

@Lurick, @Kilrah

Link to comment
Share on other sites

Link to post
Share on other sites

50 minutes ago, Furball159. said:

Thanks to both of you for that, any reccomendations on how to set up mc as a service and how i would be able to acsess its internal console via ssh and physically being there???

@Lurick, @Kilrah

You said you're running Ubuntu server, look up how to create your own systemd service, you probably want the "simple" type. You can also configure your systemd service file to auto-restart the server when it crashes, and to auto-start when the server reboots.

 

Edit: create a file called /etc/systemd/system/minecraft.service

 

Read this: https://www.freedesktop.org/software/systemd/man/systemd.service.html

 

then you can do "systemctl start minecraft" to start your server and "systemctl enable minecraft" to make it autostart on system startup. Your target should probably be "multi-user.target" and after "network.target"

Edit2: Just cuz dumping docs on someone is stupid, I'll give you an example based on a service I already run
 

[Unit]
Description=Epic 1337 Minecraft Server
After=network.target

[Service]
Type=simple
ExecStart=java /path/to/server/files/minecraft.jar
WorkingDirectory=/path/to/server/files
Restart=always
RestartSec=5
KillMode=mixed
TimeoutSec=120

[Install]
WantedBy=multi-user.target

 

Link to comment
Share on other sites

Link to post
Share on other sites

12 hours ago, ARitz Cracker said:

You said you're running Ubuntu server, look up how to create your own systemd service, you probably want the "simple" type. You can also configure your systemd service file to auto-restart the server when it crashes, and to auto-start when the server reboots.

 

Edit: create a file called /etc/systemd/system/minecraft.service

 

Read this: https://www.freedesktop.org/software/systemd/man/systemd.service.html

 

then you can do "systemctl start minecraft" to start your server and "systemctl enable minecraft" to make it autostart on system startup. Your target should probably be "multi-user.target" and after "network.target"

Edit2: Just cuz dumping docs on someone is stupid, I'll give you an example based on a service I already run
 

[Unit]
Description=Epic 1337 Minecraft Server
After=network.target

[Service]
Type=simple
ExecStart=java /path/to/server/files/minecraft.jar
WorkingDirectory=/path/to/server/files
Restart=always
RestartSec=5
KillMode=mixed
TimeoutSec=120

[Install]
WantedBy=multi-user.target

 

So over SSH how would i view the console of the game server? or would i even be able to see it when looking at it physically

Link to comment
Share on other sites

Link to post
Share on other sites

9 hours ago, Furball159. said:

So over SSH how would i view the console of the game server? or would i even be able to see it when looking at it physically

"journalctl -u minecraft.service", then press the [end] key on your keyboard to see the most recent logs. Navigate with the arrow keys. Press "Q" to exit the log view. You can also add "-e -f" at the end of the command to get a stream of most recent log entry's if that's what you want.

 

If you're asking how you would enter commands from the console, this basic setup won't allow that.

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, ARitz Cracker said:

"journalctl -u minecraft.service", then press the [end] key on your keyboard to see the most recent logs. Navigate with the arrow keys. Press "Q" to exit the log view. You can also add "-e -f" at the end of the command to get a stream of most recent log entry's if that's what you want.

 

If you're asking how you would enter commands from the console, this basic setup won't allow that.

would using ubuntu instead of ubuntu server rectify that? or would cause prefromance loss?

Link to comment
Share on other sites

Link to post
Share on other sites

2 hours ago, Furball159. said:

would using ubuntu instead of ubuntu server rectify that? or would cause prefromance loss?

Using ubuntu instead of ubuntu server doesn't make it easier to set up an always online background task like this.

This minimal service setup was always good enough for me personally, since someone had OP and if no one did, I could temporarily start the server in a shell.

 

Out of curiosity, I did some searching, haven't tried this myself, but apparently in the [Service] section of the service config file, you can expose the console input by using the StandardInput field, and I'm sure there's an easy way to utilize this, I just haven't done the experimentation myself yet.

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

  • 4 months later...

Thankyou to all of you who looked into this to help, I ended up using Crafty and getting it setup was a small chore for me, but it works perfectly now

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×