To install and run OpenSSH (Open Secure Shell), which is a suite of secure networking utilities based on the SSH protocol, follow these steps depending on your operating system. Below are instructions for Linux (Debian/Ubuntu, CentOS/RHEL) and Windows.
1. Installing OpenSSH on Linux
Debian/Ubuntu-based systems
- Update the package list:
sudo apt update
- Install OpenSSH server:
sudo apt install openssh-server
- Check the service status:
After installation, OpenSSH server starts automatically. You can check its status using:
sudo systemctl status ssh
- Start the OpenSSH server (if it’s not running):
sudo systemctl start ssh
- Enable OpenSSH to start at boot:
sudo systemctl enable ssh
- Configure the firewall (optional):
If your system usesufw
(Uncomplicated Firewall), allow SSH traffic:
sudo ufw allow ssh
sudo ufw enable
CentOS/RHEL-based systems
- Update the system:
sudo yum update
- Install OpenSSH server:
sudo yum install openssh-server
- Start and enable OpenSSH service:
sudo systemctl start sshd
sudo systemctl enable sshd
- Open firewall for SSH:
sudo firewall-cmd --permanent --add-service=ssh
sudo firewall-cmd --reload
- Check SSH service status:
sudo systemctl status sshd
2. Installing OpenSSH on Windows 10/11
Starting from Windows 10 version 1803, OpenSSH client and server are available as optional features.
Install OpenSSH Client (optional, for making SSH connections)
- Go to Settings → Apps → Optional Features.
- Click on Add a feature.
- Find OpenSSH Client, and click Install.
Install OpenSSH Server (for hosting SSH connections)
- Open Settings → Apps → Optional Features.
- Scroll down to Add a feature.
- Find OpenSSH Server, and click Install.
Start and Configure OpenSSH Server
注意使用管理员权限打开PowerShell.
- Start OpenSSH server:
Open a command prompt as administrator and run:
net start sshd
- Enable OpenSSH to start on boot:
Set-Service -Name sshd -StartupType 'Automatic'
- Allow SSH through Windows Firewall:
Open PowerShell as administrator and run:
New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
3. Connecting via OpenSSH
Once the OpenSSH server is installed and running, you can connect to it from another device using the SSH client (which is typically pre-installed on Linux or macOS systems). For Windows, you can use the OpenSSH client or third-party tools like PuTTY.
To connect to an OpenSSH server, use:
ssh username@ip_address
Replace username
with your server’s username and ip_address
with your server’s IP address or domain name.
4. Basic OpenSSH Configuration
You can configure OpenSSH by editing the sshd_config
file, typically located at:
- Linux:
/etc/ssh/sshd_config
- Windows:
C:\ProgramData\ssh\sshd_config
To apply any changes to this configuration, restart the SSH service:
sudo systemctl restart ssh
For Windows, restart the service with:
Restart-Service sshd
This guide should help you install and run OpenSSH on both Linux and Windows platforms.