27 SSH Service Basics
- Setting Up SSH on Ubuntu
- The Ubuntu machine will function as an SSH server alongside its web server role.
- SSH is a key tool for secure remote access in cybersecurity and networking.
- Before setup, check if the SSH service is already running using
systemctl status ssh
.
- Verifying SSH Service Installation
- Ubuntu uses
ssh
orsshd
for Secure Shell services. - Running
systemctl status sshd
confirms if the service is installed and active. - The default installation includes the BSD Secure Shell Server, often pre-installed.
- Ubuntu uses
- Exploring SSH Configuration Files
- SSH configurations are located in
/etc/ssh/
. - Running
ls /etc/ssh/
reveals files likesshd_config
,ssh_config
, and key files (.pub
). - The
sshd_config
file is critical for server settings, whilessh_config
is for client settings.
- SSH configurations are located in
- Understanding the
sshd_config
Filenano /etc/ssh/sshd_config
opens the SSH server configuration file.- The file includes default settings, many of which are commented out but still active.
- Important settings include
Port 22
(default SSH port) andListenAddress
.
- Adjusting SSH Security Settings
- The
PermitRootLogin
setting controls whether root can log in via SSH. PermitRootLogin no
prevents root access, enhancing security.- The
ListenAddress
option can limit SSH access to specific IPs (0.0.0.0
allows any IP).
- The
- Restarting SSH After Configuration Changes
- Changes to
sshd_config
require a service restart:systemctl restart ssh
. - Running
systemctl status ssh
verifies if the changes were applied correctly. - Misconfigurations can cause SSH access issues, requiring local troubleshooting.
- Changes to
- Testing SSH Connectivity
- The internal Kali machine is used to connect to the SSH server.
- Running
ssh sandbox@192.168.<team_number>.2
attempts a secure connection. - The first connection prompts for fingerprint verification (
yes
to accept).
- Logging into the Remote Server via SSH
- After accepting the fingerprint, SSH prompts for the user’s password.
- A successful login grants access to the Ubuntu system remotely.
- The prompt changes, indicating that commands now run on the remote server.
- Running Commands on the Remote System
- Running
pwd
confirms the remote session directory (/home/sandbox
). ip a
shows the remote machine’s IP configuration.- Remote users can edit files (
nano /etc/netplan/...
) or execute system commands.
- Running
- Closing the SSH Session
- The
exit
command logs out of the SSH session, returning to the local machine. - Understanding SSH setup and configuration enables secure remote administration.
- The
Next in Playlist: 28 SSH Service Cryptographic Keys