Access remote systems using SSH

1. Understand and Use Essential Tools

πŸ“˜Red Hat Certified System Administrator (RHCSA – EX200)


SSH stands for Secure Shell. It is the main way Linux administrators connect to remote systems securely over a network. In the RHCSA exam, you need to know how to connect, authenticate, and transfer files using SSH.


1. What is SSH and why it is important

  • SSH is a protocol that lets you log in to a remote Linux server from your local machine.
  • It encrypts your connection, so nobody can eavesdrop.
  • It is commonly used to:
    • Manage servers remotely.
    • Run commands on remote systems.
    • Transfer files securely.

Example in IT:
A server in a data center can be managed by an administrator sitting in a different location using SSH.


2. Basic SSH Command

The basic syntax to connect to a remote system:

ssh username@remote_host
  • username – the user account on the remote system.
  • remote_host – the IP address or hostname of the remote system.

Example:

ssh pooja@192.168.1.100
  • This will ask for the password of user pooja on the remote machine with IP 192.168.1.100.
  • Once authenticated, you can execute commands on the remote server.

3. SSH Keys (Password-less Login)

Instead of typing a password every time, you can use SSH key pairs:

  1. Generate a key pair on your local machine:
ssh-keygen
  • This creates two files in ~/.ssh/:
    • id_rsa β†’ private key (keep safe, do not share)
    • id_rsa.pub β†’ public key (can be shared to servers)
  1. Copy your public key to the remote server:
ssh-copy-id username@remote_host
  • After this, you can log in without a password:
ssh username@remote_host

IT Example:
Admins often use SSH keys to automate server tasks, like running scripts on 100 servers without typing passwords.


4. SSH Options

Some important SSH options for the exam:

  • Specify a port if the server is not using the default (22):
ssh -p 2222 username@remote_host
  • Run a single command on remote host without logging in interactively:
ssh username@remote_host "ls -l /var/log"
  • Enable verbose mode to troubleshoot connection issues:
ssh -v username@remote_host

5. SSH Configuration File

You can simplify SSH commands using ~/.ssh/config.

Example:

Host server1
  HostName 192.168.1.100
  User pooja
  Port 22

Now you can connect using:

ssh server1

No need to type the username or IP every time.


6. SCP – Secure Copy

SCP is used to transfer files securely over SSH:

  • Copy a file from local to remote:
scp /local/path/file.txt username@remote_host:/remote/path/
  • Copy a file from remote to local:
scp username@remote_host:/remote/path/file.txt /local/path/
  • Copy a directory recursively:
scp -r /local/dir username@remote_host:/remote/dir

IT Example:
Uploading web application files to a remote server for deployment.


7. SFTP – SSH File Transfer Protocol

SFTP is an interactive way to transfer files securely:

sftp username@remote_host

Inside SFTP session:

sftp> ls            # list files
sftp> get file.txt  # download file
sftp> put file.txt  # upload file
sftp> exit          # exit session

8. Things to Remember for the Exam

  1. SSH default port is 22.
  2. Must know how to connect using username and IP.
  3. Must know how to use SSH keys for password-less login.
  4. Must know SCP/SFTP for file transfer.
  5. Must know SSH options: -p, -v, running a command remotely.
  6. SSH config file (~/.ssh/config) can simplify connections.

9. Quick Summary Table

TaskCommand Example
Connect to serverssh pooja@192.168.1.100
Connect with specific portssh -p 2222 pooja@192.168.1.100
Generate SSH key pairssh-keygen
Copy public key to serverssh-copy-id pooja@192.168.1.100
Run remote commandssh pooja@192.168.1.100 "ls -l /etc"
Copy file to remote serverscp file.txt pooja@192.168.1.100:/tmp
Copy file from remote serverscp pooja@192.168.1.100:/tmp/file.txt ./
SFTP sessionsftp pooja@192.168.1.100

βœ… Key Exam Tip: On RHCSA, you may be asked to connect to a remote server, create keys, copy files, or run a command remotely. Practice these commands until they become second nature.

Buy Me a Coffee