Files
my-docs/Linux/Basic Administration/08-setup-ssh.md
2025-08-04 16:11:34 +03:30

2.5 KiB
Raw Blame History

🔐 Secure Shell (SSH) Remote Access & Management

SSH (Secure Shell) is a cryptographic network protocol that allows users to securely access and control remote machines over a network. It's a foundational tool for system administrators, developers, and anyone managing remote systems.


🧠 What SSH Does

  • 🔒 Encrypts Communication All data transmitted between the client and the remote server is encrypted, protecting it from eavesdropping and man-in-the-middle attacks.

  • 🧑‍💻 Authenticates Users Supports both password-based and public key-based authentication to ensure that only authorized users gain access.

  • 💻 Enables Remote Command Execution Run commands on a remote machine as if you're using its terminal directly.

  • 📁 Supports Secure File Transfers Tools like scp (Secure Copy) and sftp (SSH File Transfer Protocol) allow encrypted file transfers between machines.


🚀 Installing the SSH Server

To accept SSH connections on a machine, you must install and start the OpenSSH server.

On Debian/Ubuntu systems

sudo apt install openssh-server
  • This installs the OpenSSH daemon (sshd), which listens for incoming SSH connections.
  • To enable and start the service:
sudo systemctl enable ssh
sudo systemctl start ssh

On RHEL/CentOS systems

sudo yum install openssh-server
  • Start and enable the SSH service:
sudo systemctl enable sshd
sudo systemctl start sshd

🛠️ Common SSH Usage Examples

🔗 Connect to a Remote Server

ssh username@remote_host

📁 Copy a File to a Remote Server Using scp

scp file.txt user@remote_host:/path/to/destination/

📥 Copy a File from a Remote Server

scp user@remote_host:/path/to/file.txt .

🗂️ Use Interactive File Transfer with sftp

sftp user@remote_host

To use SSH without typing a password every time, you can set up key-based authentication:

  1. Generate SSH key pair on your local machine:
ssh-keygen
  1. Copy the public key to the remote server:
ssh-copy-id user@remote_host
  1. Now you can SSH without a password prompt:
ssh user@remote_host

Final Notes

  • SSH is a vital tool for managing servers securely.
  • Always disable root login and use key authentication for better security.
  • You can configure SSH behavior in /etc/ssh/sshd_config.