The default port for SSH (Secure Shell) is port 22.
Understanding SSH Ports
SSH is a protocol that allows for secure communication between two systems. It's frequently used for remote administration, file transfers, and secure tunneling. When establishing an SSH connection, a specific port number on the server is targeted.
Default Port
As the reference states, "By default, the SSH server still runs in port 22." This is a widely recognized standard and is the most common port on which SSH servers listen.
Port Customization
While port 22 is the default, it's possible to change the SSH port for security reasons. Here's why you might change it and how:
- Security through Obscurity: Changing the port can make it slightly harder for automated attacks to target your SSH server. Automated scanners often look for SSH on the default port 22.
- Avoiding Conflicts: If another service uses port 22, you will need to change the SSH port to prevent conflicts.
- Configuration: The SSH server configuration file usually allows changing the listening port.
- On Linux systems, this file is often located at
/etc/ssh/sshd_config
. - You'll need to find the line that says
Port 22
and change it to your desired port number. - Restart: After making the change you will need to restart the SSH service for the change to be applied.
- On Linux systems, you may use commands like
sudo systemctl restart sshd
orsudo service ssh restart
, depending on the distribution.
Connecting with a Custom Port
If you change the port, you'll need to specify it when connecting:
- SSH Command Example: Use the
-p
flag followed by the new port number:ssh -p <custom_port> user@host
. - Example: To connect to host with a custom port of 2222:
ssh -p 2222 user@host
Default Port Table
Service | Default Port |
---|---|
SSH | 22 |