![]() |
Controlling servers from a distance is an extremely important job for system admins, users, and programmers. It guarantees that the servers are operating correctly, and safely, and are current with the newest software updates. A highly effective tool for handling remote servers is the Ubuntu terminal. This guide will take you through the process of setting up, overseeing, and keeping remote servers in good shape, offering you key commands and top tips. Table of Content
Setting-Up SSH (Secure Shell)STEP 1: Installing SSH on UbuntuTo start managing a remote server, A user needs SSH installed in their OS or Ubuntu System. Then run the following commands: sudo apt update
sudo apt install openssh-server
STEP 2: Configuring SSH ServerAfter installation, Make sure the SSH server is running perfectly: sudo systemctl enable ssh
sudo systemctl start ssh
STEP 3: Generating SSH KeysSSH keys enhance security. Generating a key pair using: ssh-keygen -t rsa -b 4096 -C "[email protected]" Basic SSH Commands to Connect Remote ServerSTEP 1: Connecting to a Remote ServerFor Connecting, Use: ssh username@remote_host
STEP 2: Executing Commands RemotelyRun the commands on the remote server directly: ssh username@remote_host 'command_to_run'
STEP 3: Transferring Files with SCPSecurely copy files between your local machine and the remote server: scp localfile username@remote_host: /path/to/remote/directory
STEP 4: Using SFTP for File ManagementFor more interactive file transfer sessions, use SFTP: sftp username@remote_host
Advanced SSH TechniquesSTEP 1: SSH Tunneling and Port ForwardingNow, securely access services on your remote server by creating tunnels: ssh -L local_port:remote_host:remote_port username@remote_host
STEP 2: Managing Multiple Servers with SSH Config FileSimplify connections using an SSH config file ( Host server1 HostName remote_host1 User username IdentityFile ~/.ssh/id_rsa STEP 3: Using SSH Agent for Key ManagementLoad the keys into the SSH agent for easier access: ssh-add ~/.ssh/id_rsa
STEP 4: Setting Up SSH MultiplexingSpeed up multiple SSH connections by configuring multiplexing: Host * ControlMaster auto ControlPath ~/.ssh/sockets/%r@%h-%p ControlPersist 600 Monitoring Remote ServersSTEP 1: Installing and Using htop for Resource MonitoringInstall htop for a real-time view of system performance: sudo apt install htop
htop STEP 2: Using netstat for Network MonitoringCheck active connections and listening ports: netstat -tuln
STEP 3: Checking Disk Usage with df and du Monitor disk space usage: df -h
du -sh /path/to/directory
STEP 4: Monitoring Logs with tail and grep Track log files for issues: tail -f /var/log/syslog
grep "error" /var/log/syslog
Managing Services on Remote ServersSTEP 1: Starting and Stopping ServicesControl services using systemctl: sudo systemctl start service_name
sudo systemctl stop service_name
STEP 2: Checking Service Status Now, check the status of a service: sudo systemctl status service_name
STEP 3: Managing Services with systemctlEnable or disable services at startup: sudo systemctl enable service_name
sudo systemctl disable service_name
Remote Server MaintenanceSTEP 1: Updating and Upgrading PackagesKeep your server updated: sudo apt update
sudo apt upgrade
STEP 2: Scheduling Tasks with cronAutomate tasks using cron jobs: crontab -e
STEP 3: Performing Backups with rsyncBackup data efficiently: rsync -avz /source/directory /destination/directory
STEP 4: Disk Management and Partitioning
Security Best PracticesSTEP 1: Configuring Firewalls with ufw Set up a firewall for added security: sudo ufw allow ssh
sudo ufw enable
STEP 2: Using Fail2Ban to Prevent Brute Force AttacksInstall and configure Fail2Ban: sudo apt install fail2ban
STEP 3: Regularly Updating Software for Security PatchesEnsure all software is up-to-date to prevent vulnerabilities: sudo apt update
sudo apt upgrade
STEP 4: Setting Up Two-Factor Authentication (2FA)Adding an extra protection of security with 2FA for user’s benefits. Tools for Enhanced Remote ManagementSTEP 1: Using tmux and screen for Persistent SessionsKeeping sessions alive even after disconnecting: tmux screen STEP 2: Installing and Configuring Ansible for AutomationAutomate server management tasks with Ansible. STEP 3: Utilizing Monitoring Tools like Nagios and ZabbixSet up comprehensive monitoring for your servers. ConclusionControlling servers located far away through the Ubuntu command line is a strong and effective method for keeping your systems up and running. By becoming skilled in SSH, using monitoring software, managing services, and following top security practices, you can make sure your servers operate without problems and are safe. Consistent upkeep and oversight are crucial for avoiding problems and keeping your systems performing at their best. ![]() Remote Server Management from the Ubuntu Terminal – FAQ’sWhat are the recommended security measures for handling remote servers through SSH?
What are the fundamental steps to configure SSH for managing remote servers on Ubuntu?
How can I establish a connection to a remote server via SSH from an Ubuntu terminal?
|
Reffered: https://www.geeksforgeeks.org
TechTips |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 26 |