How to install Terraria TShock Server on Ubuntu Server? - ssh

Recently I decided to install Terraria server on Ubuntu Linux, but didn't find any completed instructions, so I decided to make my own, to help pure Terraria fans like me. This arcticle is relevant on 15.02.2019.

So first of all, you need a dedicated server. I used vps server from Heztner guys, but you can use any kind of tech you want (like raspberry pi or old pc with Ubuntu Server installed. Just make sure its minimal configuration fits Terraria Server).
After you first powered up your device and created password, we'll install SSH to make our setting up process a little bit comfy. You will be able to access server with any other device, if you have ssh installed in cmd or terminal.
Windows 10
Has SSH preinstalled in cmd. So all you need to do is
Type ssh-keygen (it will ask you to point the folder to extract keys, you can do it or just press enter)
Type ssh-copy-id "username"#"yourdeviceip" (Example: root#116.23.106.75)(In username type root)
Enter root password and you're in ')
Ubuntu 18.04
You may need to enable SSH in terminal. Use this instruction. Process is the same as in cmd on Windows 10.
Also
You can use SSH clients like Termius, you just need to create new Host with enabled SSH and put your server ip. Then choose user and enter password, and you're in.
Finally we're done with SSH and begining to setup our working environment. To fully operate with our system, we need to install several programs, as
mono-complete (to emulate windows shell environment, so TShock can work properly)
screen (to detach our terraria server screen)
unzip
And finally our Terraria server
Installation
First we create different user, so we store Terraria files separately of root.
adduser terraria
Then add it to sudo group, so you can launch several admin commands
adduser terraria sudo
Then install programs
sudo apt-get install mono-complete screen unzip
Enter as terraria user
su terraria
Go to your home folder
cd
Download latest TShock file, for me it's 4.3.25. If there is newer version, just go to their github page and copy zip file download link and paste it instead of mine.
sudo wget https://github.com/Pryaxis/TShock/releases/download/v4.3.25/tshock_4.3.25.zip
Unzip it
unzip tshock_4.3.25.zip
Delete zip-file
rm tshock_4.3.25.zip
Execute server one time to create the map
mono-sgen TerrariaServer.exe (type it every time you want to launch the server)
And now, when the map created and launched, you simply press ctrl+a to start screen, and then press d. Now your screen is detached and you can use your console regardless of server. Also this wont let your Terraria process shut down because of inactivity.
Bonus level
And this part will be for people who want to transfer their local map to server. I did it because first time I played Terraria with friends through Steam, and then I created server so map can run 24/7.
All you need to do is create ssh connection from device you store your local map. If you did it previously, then go to your Steam folder, find Terraria worlds, right click, properties and copy the path. Then go to cmd and type
scp "yourworldpath" terraria#*yourserverip*:~
It will copy your local world to home section, then go back to your ssh with terraria user and type
cd
mv "yourworldname" .local/share/Terraria/Worlds/
That thing will move your world file to hidden .local folder, where all world files store. Aaaand that's all. Just go to number 8 and do it again. Hope this guide will help you:) If you find any mistakes or face with problems, just comment this section, so I can fix it.

Related

Cygwin: ssh and ssh-keygen do not react at all

I've got a strange behaviour of ssh and ssh-keygen: they do not react at all. Cygwin is started with admin rights and works normally. The host 192.168.1.1 is up and I can remote desktop to it:
When I try:
$ ssh -vvv pi#192.168.1.1
OpenSSH_8.3p1, OpenSSL 1.1.1f 31 Mar 2020
I get only one line but nothing else, even if I wait hours. I reinstalled cygwin, openssh, I deleted the .ssh folders, no success.
When I enter
ssh-keygen -b 4096
nothing happens at all. For me it seems that the user interaction does not work. Any ideas?
Thanks
Update: I tried:
reinstalling cygin for all users, one user, running the installation with admin rights, without. No success.
Started ssh and ssh-keygen with an absolute path to make sure that the windows openssh is not used
Checked the folder permissions on .ssh
Here is my strace: Pastebin
Update 2: I found the following: if I run ssh-keygen or ssh often enough (!) it will sometimes work! Now that's weird.
Philippe had the right idea. Basically the citrix workspace app is crashing ssh cygwin. When I uninstalled citrix everything worked fine!
I found that it is down to a bug in epclient64.dll of citrix: it crashes my ssh in my internal network. After uninstallation of citrix it would work normally. Here is the log
Pastebin log of strace
https://pastebin.com/FJfUj3C1[Pastebin][1]
Without the app protection it works fine. So to sum up:
with app protection ssh crashes again and again, it does not even start properly
without citrix ssh works fine
citrix without app protection ssh works fine
--> epclient64.dll does not work with ssh
And we are talking about the most recent versions of ssh & citrix as of Jan 2021.
I found that when I uninstalled citrix, it had no effect.
I opened up the folder in Windows Explorer where the ssh.exe resides. I right clicked on this executable, navigated to Compatibility tab, selected Run this program in compatibility mode for "Windows 8". Then I at least got a response from the command line, but it would never connect to the host I entered. It would get stuck and I would have to kill it from taskmgr.
When I ran whereis ssh, I had 2 versions in Cygwin, one in /usr/bin and one in /cygdrive/c/WINDOWS/System32/OpenSSH. So what I did was to move the /usr/bin version to a backup file and create a link in a cygwin shell to /cygdrive/c/WINDOWS/System32/OpenSSH/ssh.exe. Now it works like it used to.
By the way my OpenSSH version is "OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5" running on Windows 10.

Cygwin disappeared on its own and messed up my downloads folder permissions (I think)

I am trying to get Autossh to work with Cygwin.
I followed this guide loosely:
http://tutorialspots.com/how-to-create-ssh-tunnel-on-windows-by-using-autossh-2984.html
I managed to get as far as setting up my ssh keys ad ssh'ing into my server. I did that by copying my windows .ssh folder into the one that Cygwin uses with the cp command, so I skipped the key-generating section of the guide since I have my own.
I installed the packages AutoSSH, OpenSSH, OpenSSL, Zip, Unzipsnd also vim.
So here's the really weird part:
I copied the ssh keys, ssh'ed into my server and all went fine. Then tried to use autossh with the -M command, but everything was gone. It's like the /usr/bin folder disappeared.
Then I saw that the installation file i got from https://cygwin.com/ also disappeared. And the shortcuts on my desktop and start menu has also deleted itself.
This has happened twice now after successfully ssh'ing into my server once. So it seems on the second attempt, everything deletes itself.
Even worse, when I try to download the installation file into my Downloads folder in my user directory, chrome says "Failed: Insufficient permissions".
Interestingly it only does this with the installation file. I can download any other files from any other location(it seems). If I tell chrome to use a different download folder, I can suddenly download cygwin again.
I am so confused.
Can anyone help?

Can Vagrant suffice my requirement?

I have been looking out for ways to setup an automation environment and I found this application named Vagrant. I read the docs on the site, however I wanted to know from the experts out there if Vagrant with Oracle VirtualBox would suffice my needs.
I need to have a script that will call Vagrant to initialize a VM [The VM-Image is always the same - Windows Server 2008 R2]
I need to copy some of my project related files from a shared location onto the VM
Call a Batch file that will take care of test runs for me inside the VM
Once my test run is complete, This VM needs to be self destroyed/destructed.
Also, I would like to know if the Image be a custom .ISO file?
Sounds like Vagrant and VirtualBox will work for that scenario. Also, you might find that running commands in the VM using WinRM or SSH may be the easiest way to launch tests.
If you haven't already seen it, the blog post about Windows support in Vagrant 1.6 is informative: https://www.vagrantup.com/blog/feature-preview-vagrant-1-6-windows.html
Creating a VirtualBox/Vagrant base VM from an .iso should work, and you can then do all of your work using the VM from that point onward.
To get started, you might try these steps:
Create a VirtualBox VM from your Windows .iso, using the VirtualBox GUI or cmdline tools.
Once you have the VM in the state you want it, shut it down and package it as a vagrant box - for example, on a Mac that step looks like (where Win7x64 is the dir containing the VirtualBox VM):
cd ~/VirtualBox\ VMs
vagrant package --base Win7x64 --output win7x64_base.box
Once that finishes, tell vagrant about the new base box:
vagrant box add win7x64_base /path/to/win7_base.box
Then you can vagrant init/vagrant up the VM:
mkdir win7 && cd win7
vagrant init win7x64
vagrant up
To enable SSH access, I installed Cygwin in the VM and configured sshd. So, after launching you can SSH in by running vagrant ssh
Note that if there's no Windows user in the VM named 'vagrant', you can specify the SSH username to use with vagrant ssh by placing this in your Vagrantfile:
config.ssh.username = 'user1'
As mentioned above, WinRM is also an option for remotely running commands.
And Vagrant apparently has some convenience features to make it easy to RDP into the VM, but I haven't looked at that.

Fedora how to automatically run the ssh daemon

I would like to know what are the ways to automatically start daemons (sshd) in Fedora system. I know I can write a startup script that will put on /etc/init.d/.
What are the other options?
Somewhere I read that now in the new version of this can be done using the commands in the terminal, but I do not remember what it was.
EDIT: My 2 question.
I install ssh from source. When keys are generated for a server? During the installation?
You can do this via systemctl:
systemctl enable sshd.service

Vagrant and / or Docker workflow with full OS X filesystem integration for seamless local feel?

Recently I've been dabbling with vagrant and docker. These are quite interesting tools, but I haven't been able to convince myself that it's the way to go quite yet on my OS X machine. Being an old Unix hat, I have to say that I like having a consolidated and sandboxed environment for development purposes.
I've seen a lot of chatter and a number of friends have been using vagrant with just stock vim for editing. I'm not really a fan of that approach and would probably prefer to use the vm provider's sharing mechanism OR, more likely, NFS.
Personally I'd like to be able to edit directly in TextMate, SublimeText, Emacs (on OS X), or even perhaps use RubyMine and its various IDE features, etc.
Is there any way to really get the workflow down so that such an environment will be essentially like working on a local environment without having to pull a lot of additional background strings to make things work out?
I suppose a few well placed scripts could go a long way, but I've not found any solid answers on really making this a seamless environment.
What actually worked for me was to use boot2docker which makes it easy to install a lightweight virtual machine (with VirtualBox) that will host your docker deamon and images. The only thing you need in order to run docker commands is to run $(boot2docker shellinit) when you open a new Terminal.
If you need to also have your files on an OS X folder and share them with a running docker image, you need some additional setup, but once you do it, you won't have to do it again.
Have a look here for a nice walkthrough on how to do it. The steps in short are:
Get a special boot2docker image that allows you to use shared folders for VirtualBox
Configure VirtualBox to share a folder:
VBoxManage sharedfolder add boot2docker-vm -name home -hostpath /Users
This will share your /Users folder with the boot2docker image that hosts docker.
From you Mac share the folder you need with a folder in a docker image like:
docker run -it -v /Users/me/dev/my-project:/root/src:rw ubuntu /bin/bash
One small annoyance that I haven't found how to overcome is that you do not longer access your software through localhost because it actually runs on boot2docker instance. You have to run boot2docker ip and access that ip.
Hope that helps!