diff --git a/create_ssh_key.md b/create_ssh_key.md new file mode 100644 index 0000000..f96d33a --- /dev/null +++ b/create_ssh_key.md @@ -0,0 +1,34 @@ +## Creating and Using SSH Keys + +### Understanding SSH Keys +SSH keys provide a secure method for authenticating to remote servers. They consist of a public key and a private key. The public key is shared with the server, while the private key remains on your local machine. + +### Generating an SSH Key Pair + +To generate a new SSH key pair, open your terminal and run the following command: +```bash +ssh-keygen -t ed25519 -C "your_email@example.com" +``` +Replace your_email@example.com with your actual email address. +You will be prompted to enter a passphrase for added security. It's recommended to use a strong passphrase. Store this passphrase as it will be one of our login methods. + +The generated keys will be stored in the following files: + +Private key: ~/.ssh/id_ed25519 +Public key: ~/.ssh/id_ed25519.pub + +### Adding Your Public Key to the Server + +1. Copy the contents of the public key file: + +2. On your server, log in as the user you created. + +3. Create the .ssh directory: mkdir -p ~/.ssh + +4. Create the authorized_key file:touch ~/.ssh/authorized_keys + +5. Set permissions: +```bash +chmod 700 ~/.ssh +chmod 600 ~/.ssh/authorized_keys +``` diff --git a/create_user.sh b/create_user.sh new file mode 100644 index 0000000..61188e3 --- /dev/null +++ b/create_user.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +function create_user() { + read -p "Enter username: " username + + sudo useradd -m -d /home/$username $username + sudo usermod -aG sudo $username + + sudo mkdir -p /var/www/apps /var/www/static + + echo "User $username created with sudo privileges" + echo "Apps directory created: /var/www/apps/" + echo "Static files directory: /var/www/static" + echo "Next step: Create SSH keys. Refer to: [link to SSH key creation guide]" +} + +create_user diff --git a/install_docker.sh b/install_docker.sh new file mode 100644 index 0000000..37e159f --- /dev/null +++ b/install_docker.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# Install prerequisites +sudo apt-get update +sudo apt-get install -y ca-certificates curl + +# Create directory for GPG key +sudo mkdir -p /etc/apt/keyrings + +# Download and install Docker GPG key +sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc +sudo chmod a+r /etc/apt/keyrings/docker.asc + +# Add Docker repository to sources.list +echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list >/dev/null + +# Update package lists +sudo apt-get update + +# Install Docker Engine, CLI, containerd, Buildx plugin, and Compose plugin +sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin + +echo "Docker installation completed!" diff --git a/install_nginx.sh b/install_nginx.sh new file mode 100644 index 0000000..3dd0e9b --- /dev/null +++ b/install_nginx.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +# Function to create the static configuration template +function create_static_config() { + cat << EOF > /etc/nginx/sites-available/static.example.conf + server { + listen 80; + server_name (YOUR_DOMAINS); + + root (CONTENT_PATH); + + error_page 404 /; + + index index.html index.htm index.nginx-debian.html; + + location / { + try_files $uri $uri/ =404; + } + } + EOF + echo "Created static configuration template: /etc/nginx/sites-available/static.example.conf" +} + +# Function to create the API configuration template +function create_api_config() { + cat << EOF > /etc/nginx/sites-available/api.example.conf + server { + listen 80; + server_name YOUR_API_DOMAIN; + location / { + proxy_pass http://localhost:(API_PORT)/; + } + } + EOF + echo "Created API configuration template: /etc/nginx/sites-available/api.example.conf" +} + +# Function to install Nginx +function install_nginx() { + sudo apt update + sudo apt install -y nginx + sudo systemctl start nginx + sudo systemctl enable nginx +} + +install_nginx +create_api_config +create_static_config +sudo systemctl restart nginx + +echo "To enable these configurations, create symbolic links to /etc/nginx/sites-enabled:" diff --git a/setup.sh b/setup.sh index 81b8c02..3f925db 100644 --- a/setup.sh +++ b/setup.sh @@ -1,38 +1,8 @@ #!/bin/bash -# Update and install necessary packages -sudo apt update -sudo apt install -y curl gnupg lsb-release - -# Install Node.js -curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - -sudo apt install -y nodejs - -# Install PM2 -sudo npm install -g pm2 - -# Install Nginx -sudo apt install -y nginx - -# Create files and directories -sudo mkdir -p /var/www/myapp -sudo touch /var/www/myapp/index.html -sudo ln -s /var/www/myapp /var/www/html/myapp - -# Set up default Nginx config -cat <