0% found this document useful (0 votes)
24 views5 pages

If It S Your First Time

This document provides a comprehensive step-by-step guide for setting up and configuring a cloud server for first-time users. It covers essential tasks such as creating a new user, setting up SSH access, updating software, configuring a firewall, installing web servers, and deploying applications. Additionally, it emphasizes security measures like disabling root login and installing monitoring tools.

Uploaded by

vickymuthunga
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views5 pages

If It S Your First Time

This document provides a comprehensive step-by-step guide for setting up and configuring a cloud server for first-time users. It covers essential tasks such as creating a new user, setting up SSH access, updating software, configuring a firewall, installing web servers, and deploying applications. Additionally, it emphasizes security measures like disabling root login and installing monitoring tools.

Uploaded by

vickymuthunga
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

If it's your first time using a cloud server (like Alibaba Cloud, AWS, or any other

cloud provider), here is a step-by-step guide on setting up and configuring the


server, especially when you're using a user account for the first time. This guide
includes creating a user, setting up basic configurations, securing the server, and
deploying your application.

Step-by-Step Guide for Setting Up Your Server


1. Access the Server (First Time Login)
Access the server via SSH:

Use an SSH client (like ssh on Linux or macOS, or an SSH client like PuTTY on
Windows) to connect to your cloud server.
You will typically use the public IP of the server and the private SSH key (if
you've set up SSH key-based authentication during server creation).
Example SSH command:

bash
Copy code
ssh -i /path/to/your/private-key.pem root@your-server-ip
Initial login:

You’ll log in as the root user for the first time.


You will see a prompt and, after connecting, be logged into the server as root by
default.
2. Create a New User
It’s recommended not to use the root account for day-to-day tasks. Instead, create
a new user account with administrative privileges (via sudo).

Create a new user:

bash
Copy code
adduser myusername # Replace 'myusername' with the name you want for the user
Set a password for the new user:

bash
Copy code
passwd myusername # You will be prompted to enter and confirm a password
Grant the new user sudo access: Add the new user to the sudo group so they can
perform administrative tasks.

bash
Copy code
usermod -aG sudo myusername
Test the new user: Switch to the new user account to ensure everything works as
expected:

bash
Copy code
su - myusername
Exit back to root:

bash
Copy code
exit
3. Set Up SSH Access for the New User (Optional)
If you want to use SSH keys for authentication, follow these steps to configure SSH
access for the new user:
Create a .ssh directory for the new user:

bash
Copy code
mkdir /home/myusername/.ssh
chmod 700 /home/myusername/.ssh
Add your SSH public key: Copy your SSH public key (typically located in
~/.ssh/id_rsa.pub on your local machine) and paste it into the authorized_keys
file.

bash
Copy code
echo "your-ssh-public-key" > /home/myusername/.ssh/authorized_keys
chmod 600 /home/myusername/.ssh/authorized_keys
chown -R myusername:myusername /home/myusername/.ssh
Disable root login via SSH (optional but recommended): To secure your server, it’s
good practice to disable root login via SSH. Edit the SSH configuration file:

bash
Copy code
nano /etc/ssh/sshd_config
Change the line:

bash
Copy code
PermitRootLogin yes
to:

bash
Copy code
PermitRootLogin no
Restart SSH:

bash
Copy code
systemctl restart sshd
4. Update and Install Basic Software
Update your system: Run an update to make sure the system is up to date.

bash
Copy code
sudo apt update && sudo apt upgrade -y # For Ubuntu/Debian-based systems
sudo dnf update -y # For Fedora/RHEL-based systems
Install basic software: Install essential utilities like git, curl, vim, and others
that you might need:

bash
Copy code
sudo apt install git curl vim -y # For Ubuntu/Debian
sudo dnf install git curl vim -y # For Fedora/RHEL
5. Set Up a Firewall
Configuring a firewall is crucial for securing your server.

Enable UFW (Uncomplicated Firewall):


Check UFW status:
bash
Copy code
sudo ufw status
Allow SSH and HTTP traffic:
bash
Copy code
sudo ufw allow OpenSSH
sudo ufw allow http
sudo ufw allow https
Enable UFW:
bash
Copy code
sudo ufw enable
6. Install Nginx/Apache for Web Server (If needed)
If you are deploying a web application and need a reverse proxy for your Node.js or
other apps, you’ll likely use Nginx or Apache.

Install Nginx (for example):

bash
Copy code
sudo apt install nginx -y # For Ubuntu/Debian
sudo dnf install nginx -y # For Fedora/RHEL
Start and enable Nginx:

bash
Copy code
sudo systemctl start nginx
sudo systemctl enable nginx
Verify Nginx is running: Open your server’s public IP in a browser and check if you
see the Nginx welcome page.

7. Set Up a Node.js Environment (if applicable)


Install Node.js: Use Node Version Manager (NVM) for flexibility.

Install NVM:
bash
Copy code
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
Install Node.js via NVM:
bash
Copy code
nvm install node # This installs the latest version
Check Node.js installation:

bash
Copy code
node -v
npm -v
8. Set Up Git for Version Control
Install Git:

bash
Copy code
sudo apt install git -y # For Ubuntu/Debian
sudo dnf install git -y # For Fedora/RHEL
Configure Git:

bash
Copy code
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
9. Deploy Your Application
Clone your app from a Git repository or upload files directly.

Example (if using Git):


bash
Copy code
git clone https://github.com/your-repo.git /home/myusername/myapp
Install dependencies: Navigate to your app directory and install necessary
dependencies:

bash
Copy code
cd /home/myusername/myapp
npm install
Start your application: You can use PM2 to manage your Node.js application.

bash
Copy code
npm install pm2 -g
pm2 start app.js
pm2 save
10. Set Up a Reverse Proxy with Nginx
Configure Nginx to reverse proxy to your Node.js app (e.g., running on port 3000):

bash
Copy code
sudo nano /etc/nginx/sites-available/myapp.conf
Example Nginx config:

nginx
Copy code
server {
listen 80;
server_name myapp.com;

location / {
proxy_pass http://localhost:3000; # Change to your app's port
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
Enable your configuration:

bash
Copy code
sudo ln -s /etc/nginx/sites-available/myapp.conf /etc/nginx/sites-enabled/
sudo systemctl restart nginx
11. Monitor and Secure Your Server
Install Fail2ban (to protect against brute-force attacks):

bash
Copy code
sudo apt install fail2ban -y # For Ubuntu/Debian
sudo dnf install fail2ban -y # For Fedora/RHEL
Set up monitoring tools (optional, e.g., htop or glances):
bash
Copy code
sudo apt install htop # For Ubuntu/Debian
sudo dnf install htop # For Fedora/RHEL
Conclusion
Following these steps will set you up with a well-secured, multi-user environment
for deploying applications on your cloud server. You'll have:

A dedicated user for each application or task.


A secure server with an SSH key and firewall in place.
The tools needed to deploy, manage, and monitor your applications.

You might also like