Windows系统远程连接到Linux系统
1.使用Windows内置的SSH客户端
按下Win + R键,输入cmd并按Enter打开命令提示符。
输入`ssh username@hostname`命令并按Enter。其中,`username`是Linux系统上的用户名,`hostname`是Linux系统的IP地址或主机名。
如果是首次连接,系统会提示确认连接的指纹,输入yes继续,然后输入Linux系统的密码。
2.使用PuTTY(免费的SSH客户端)
从PuTTY的官方网站下载并安装PuTTY。
打开PuTTY应用程序,在“HostName (or IPaddress)”字段中输入Linux系统的IP地址或主机名。
确保“Connection type”选择为SSH,然后点击“Open”按钮。
在弹出的终端窗口中,输入Linux系统的用户名并按Enter,然后输入密码并按Enter。
3.使用Windows Subsystem for Linux (WSL)
如果已在Windows上安装了WSL,可以直接在WSL终端中使用SSH命令。
在开始菜单中搜索“WSL”或“Ubuntu”等,打开WSL终端。
输入`ssh username@hostname`命令并按Enter,然后输入密码以完成连接。
Linux系统远程连接到Linux系统
使用SSH命令
在Linux系统的终端中输入`ssh username@hostname`命令并按Enter。其中,`username`是远程Linux系统上的用户名,`hostname`是远程Linux系统的IP地址或主机名。
连接成功后,会要求输入密码进行身份验证。
注意事项
确保Linux系统上已安装并运行SSH服务器(通常是sshd服务)。
确保网络设置允许从Windows或Linux系统到远程Linux系统的SSH连接。如果使用防火墙,请确保端口22(默认SSH端口)是开放的。
如果无法连接,可能是SSH服务器未打开或防火墙设置问题。可以通过以下命令检查SSH服务状态并启动SSH服务:
Debian/Ubuntu:`sudo apt update; sudo apt install opensshserver; sudo systemctl start ssh; sudo systemctl enable ssh`
CentOS/RHEL:`sudo yum install opensshserver; sudo systemctl start sshd; sudo systemctl enablesshd`
Fedora:`sudo dnf install opensshserver; sudo systemctl start sshd; sudo systemctl enablesshd`
使用ufw(Ubuntu/Debian)或firewalld(CentOS/RHEL/Fedora)等防火墙管理工具来允许SSH连接。