Skip to content

Linux step by step with SSH and Fire Wall

Mag-nus edited this page Apr 24, 2024 · 71 revisions

Setup for letting others access your Linux-based ACE Server. This will work with most distros, Ubuntu 20.04 with a desktop environment was used for the instructions below.

SSH setup:

More information: https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_keymanagement

  • Generate a key, shove the public key in OpenSSH format in ~/.authorized_keys This looks like a file containing `ssh_rsa 'DASFASFASVFHDASVFHDASVFDASFDSAFASDFDASFADFSFVASFVDASFVHASDVFHASDVFHADSVFHDASVFHDASV some comment' you'll be able to log in as the user you shove the key into the folder of.
  • If using WinSCP for sftp management, import key using PuTTYgen and save in .ppk format in your .ssh folder as well
  • Check that you can log in without a password (using the key)
  • Use Nano or Vim to edit /etc/ssh/sshd_config
  • Change your ssh port to something other than 22, this isn't a security measure, it is just to avoid getting your logs spammed by bots. Use 2222 if you cannot choose something
  • Optionally set PermitRootLogin to yes, some will argue you should never log in as root to a server some will
  • Set PasswordAuthentication to no, make sure the key works before doing this
  • sudo systemctl restart sshd
  • sudo systemctl status sshd ensure its running

Firewall setup:

  • sudo ufw allow [yoursshport] make sure you rebooted sshd otherwise it won't have your new port and will refuse connections
  • sudo ufw allow 9000 allow game ports
  • sudo ufw allow 9001
  • sudo ufw enable this will enable the firewall, possibly dropping your ssh connection

Once ssh is setup, installation can be done headless

Use SSH + WinSCP/Filezilla to complete the following:

Github

  • Clone the main repository using git clone 'repository URL'
  • Or Optionally Fork Repository and clone using git clone 'repository URL'
  • Create a /DAT/ directory in /ACE/ and place your DAT files there: /ACE/DAT/client_cell_1.dat client_highres.dat client_local_English.dat client_portal.dat

MariaDB setup:

  • sudo apt update
  • sudo apt install mariaDB-server
    • sudo mysql_secure_installation, say yes to everything and change the root password
    • sudo mysql -p to login
  • Create 3 databases, ace_auth, ace_shard and ace_world
    • CREATE DATABASE db_name;
  • Create 3 users, ace_auth, ace_shard and ace_world with respective access to their databases (ideally you'd limit the access further) Now the firewall setup will prevent you from connecting to your DB externally but that is fine, many sql clients will have an option to use an ssh tunnel to connect. For SQL clients, Dbeaver or HeidiSQL are options that support ssh tunnelling.
    • USE db_name Selects the DB
    • CREATE USER 'username'@localhost IDENTIFIED BY 'password'; Creates the user and password
    • GRANT ALL PRIVILEGES ON 'db_name'.* TO 'username'@localhost; To grant privileges only for the DB in use
    • FLUSH PRIVILEGES; It’s crucial to refresh the privileges once new ones have been awarded
  • Load AuthenticationBase.sql ShardBase.sql WorldBase.sql for their respective databases. These can be found in the [Database\Base] path.
  • To Load:
    • USE db_name;
    • SOURCE [use the full path to 'AuthenticationBase.sql' 'ShardBase.sql' 'WorldBase.sql'];
  • Download the latest release of world data, extract and load it into your ace_world database
  • https://github.com/ACEmulator/ACE-World-16PY + https://github.com/ACEmulator/ACE-World-16PY-Patches

Dotnet SDK+Runtime:

  • https://docs.microsoft.com/en-us/dotnet/core/install/linux-ubuntu#2004, use 8.0
  • From: /home/asheron/ACE/Source/ACE.Server COPY Config.js.example and rename to Config.js when prompted as a duplicate file, then modify settings, such as DAT folder location, database credentials and other server settings per your needs. (WinSCP if headless comes in handy here)
  • In ACE/Source, run dotnet build
  • In ACE/Source/ACE.Server/bin/Debug/net8.0 run dotnet ACE.Server.dll ACE Server should now launch

Leave a Remote Instance Running:

https://linuxize.com/post/how-to-use-linux-screen/

  • Connect to your linux box using ssh
  • screen -S ACE
  • launch ACE in the newly created terminal instance, you can now close your session and ACE will continue to run

ctrl+d does not work with screens when ACE is running to detach. However, you can close the terminal window then reconnect and resume using screen -r ACE or use screen -list to view attachable screens if you named the session something else

Troubleshooting notes:

There are multiple Config.js files within the ACE directory;
/home/asheron/ACE/Source/ACE.Server/Config.js is copied to /ACE/Source/ACE.Server/bin/Debug/net8.0
when run dotnet build is entered. ACE uses the Config.js located in the net8.0 directory.
If you encounter SQL authentication errors while launching, verify your Config.js has the correct credentials in the correct location