在 Linux 世界中, 安全外壳 secure shell (SSH)协议是最为常用的、通过命令行控制远程计算机的方式。SSH 是真正的 Linux 原创,但是它在 Windows 世界中也越来越流行。甚至有了一份官方的 Windows 的 SSH 文档,那篇文档阐述了使用 OpenSSH 控制 Windows 的方法。
这篇文章展示了如何使用了流行的开源工具 PuTTY,建立一个从 Windows 到 Fedora 33 Linux 系统的 SSH 连接。
# $OpenBSD: sshd_config,v 1.100 2016/08/15 12:32:04 naddy Exp $
# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.
# This sshd was compiled with PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin
# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options override the
# default value.
Include /etc/ssh/sshd_config.d/*.conf
#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::
没有取消任何注释的默认配置在这个示例中应该是可以工作的。要检查 SSH 守护进程是否已经运行,输入 systemctl status sshd:
$ systemctl status sshd
● sshd.service - OpenSSH server daemon
Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2018-06-22 11:12:05 UTC; 2 years 11 months ago
Docs: man:sshd(8)
man:sshd_config(5)
Main PID: 577 (sshd)
Tasks: 1 (limit: 26213)
CGroup: /system.slice/sshd.service
└─577 /usr/sbin/sshd -D -oCiphers=[aes256-gcm@openssh.com][5],chacha20-[...]
在“ 主机名(或 IP 地址) Host Name (or IP address) ”输入框,键入你的 Linux 系统的连接信息。本文设置了一个 Fedora 33 虚拟机,它使用桥接网络适配器,使我可以由 IP 地址 192.168.1.60 连接这个系统。点击“ 打开 Open ”,应会如图示的打开一个窗口:
这是 SSH 的安全措施之一,是为了防止 中间人攻击 man-in-the-middle attack 。消息中的指纹应该匹配 Linux 系统中放在 /etc/ssh/ssh_host_ed25519_key.pub 的密钥。PuTTY 将这个密钥以 MD5 哈希值 的方式打印出来。要检查它的真实性,切换到 Linux 系统并打开一个控制台,然后输入: