工程师 - 安装和使用OpenSSH

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
  1. Update the package list:
   sudo apt update
  1. Install OpenSSH server:
   sudo apt install openssh-server
  1. Check the service status:
    After installation, OpenSSH server starts automatically. You can check its status using:
   sudo systemctl status ssh
  1. Start the OpenSSH server (if it’s not running):
   sudo systemctl start ssh
  1. Enable OpenSSH to start at boot:
   sudo systemctl enable ssh
  1. Configure the firewall (optional):
    If your system uses ufw (Uncomplicated Firewall), allow SSH traffic:
   sudo ufw allow ssh
   sudo ufw enable
CentOS/RHEL-based systems
  1. Update the system:
   sudo yum update
  1. Install OpenSSH server:
   sudo yum install openssh-server
  1. Start and enable OpenSSH service:
   sudo systemctl start sshd
   sudo systemctl enable sshd
  1. Open firewall for SSH:
   sudo firewall-cmd --permanent --add-service=ssh
   sudo firewall-cmd --reload
  1. 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)
  1. Go to SettingsAppsOptional Features.
  2. Click on Add a feature.
  3. Find OpenSSH Client, and click Install.
Install OpenSSH Server (for hosting SSH connections)
  1. Open SettingsAppsOptional Features.
  2. Scroll down to Add a feature.
  3. Find OpenSSH Server, and click Install.
Start and Configure OpenSSH Server

注意使用管理员权限打开PowerShell.

  1. Start OpenSSH server:
    Open a command prompt as administrator and run:
   net start sshd
  1. Enable OpenSSH to start on boot:
   Set-Service -Name sshd -StartupType 'Automatic'
  1. 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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

夜流冰

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值