1.2.0 • Published 2 months ago

initial-server-setup v1.2.0

Weekly downloads
2
License
MIT
Repository
github
Last release
2 months ago

Initial setup tool for ubuntu 18.04 remote servers based on ansible-playbook. To run this tool you have to take a look at the requirements below.

ℹ️ Successfully tested with Ubuntu 22.04. It has some strange things like using legacy repos, but it is what it is. This is not used by anyone except me anyway.

What does this tool do?

All this steps will be produced on your remote server in default configuration.

initial-server-setup setup --host 123.456.78.90

⚠️ Be careful: after this steps you will be able to login only with passed ssh keys (without password) with default or root users. To add more ssh keys to login from your another control nodes you have to install those ssh keys before.

  1. Initial ubuntu server configuration:
    1. install curl for transferring data with urls;
    2. install vim text editor to edit text files;
    3. install ufw firewall to protect ports;
    4. install git version control to manage repositories.
    5. create new user default with sudo privileges and ability to login to remote server with your local public ssh key (~/.ssh/id_rsa.pub);
    6. disable remote root login with password with PermitRootLogin prohibit-password;
    7. setup ufw tool to allow only ssh connections and some ports (http:80, https:443, :8000).
  2. Install and configure docker-ce toolbox and do post-installation steps:
    1. install docker to manage containers;
    2. configure crontab for root to run docker system prune --all --force every night to clean detached images and other docker stuff to free space after deployments.
    3. add user default to docker administrators group;
    4. pull hello nginx container nginxdemos/hello;
    5. run hello container on :8001 port inside localhost (the container isn't published to the internet yet on this step).
  3. Install and configure nginx:
    1. install nginx to manage web servers;
    2. configure nginx with default configuration;
    3. add default server to proxy all requests from public :8000 port to the nginx hello container.
  4. Install and configure certbot:
    1. install certbot to manage ssl certificates.

As the result you will get configured web server with nginx layer to manage web servers and with docker to run containers inside remote machine. Also you have to be able to see the result of nginxdemos/hello container on your-domain.com:8000. And you will be able to login to your remote server with ssh <default|root>@<remote-server-ip|remote-server-domain>.

demo

Which requirements does this tool have?

Server node requirements

Server node is a node where you want to configure the environment.

Control node requirements

Control node is a node from what you are going to run setup tool.

How to install this tool?

npm i -g initial-server-setup

How to use this tool?

Basic configuration uses root user to login into remote server and ~/.ssh/id_rsa.pub to install ssh key inside remote server. Also this tool creates user default to login into remote server with ~/.ssh/id_rsa.pub key.

initial-server-setup setup --host 123.456.78.90

Options to configure the tool

You can define the following options and full command will be like.

initial-server-setup setup --host 123.456.78.90 --root-user root --root-key ~/.ssh/id_rsa.pub --target-user default --target-key ~/.ssh/id_rsa.pub
OptionDefaultRequiredDescription
host+Remote server ip or domain.
root-userroot-Remote sudo user to login into clean server.
root-key~/.ssh/id_rsa.pub-Remote sudo user key to install inside remote server.
target-userdefault-Remote admin user to create with sudo privileges.
target-key~/.ssh/id_rsa.pub-Remote admin user key to install inside remote server.

Existed commands in the tool

You can use any command separately and every command has it own --help.

initial-server-setup setup-docker --help
CommandDescription
setup optionsGeneral command to run all setup-* commands.
setup-key optionsInstall local public key to remote host.
setup-ubuntu optionsDo initial ubuntu setup.
setup-docker optionsDo docker-ce setup and run hello container.
setup-nginx optionsDo nginx setup and run hello server for the hello container.
setup-certbot optionsDo certbot installation with nginx module.

Install additional ssh keys to remote server

Copy and paste your ssh public key from another control node to what you want to give access via the following command (do not forget to use -f flag).

ssh-copy-id -f -i ~/.ssh/different-key.pub <remote-server-ip|remote-server-domain>
1.2.0

2 months ago

1.1.5

3 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago