1.检查windows中ssh配置
- 查找“OpenSSH 客户端”
- 查找“OpenSSH 服务器”
以上二者是否安装成功
2.检查电脑是否安装以上远程连接需要的工具,以管理员的身份打开powershell
然后执行此命令检查:
Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'
二者都没有安装会返回:
Name : OpenSSH.Client~~~~0.0.1.0
State : NotPresent
Name : OpenSSH.Server~~~~0.0.1.0
State : NotPresent
3.下载二者程序执行一下指令:
# Install the OpenSSH Client
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
# Install the OpenSSH Server
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
电脑没有那个程序执行那个命令即可;
执行之后下载成功会返回:
Path :
Online : True
RestartNeeded : False
完成下载;
4.启动openssh服务器及配置相关的配置问题
# Start the sshd service
Start-Service sshd
# OPTIONAL but recommended:
Set-Service -Name sshd -StartupType 'Automatic'
# Confirm the Firewall rule is configured. It should be created automatically by setup. Run the following to verify
if (!(Get-NetFirewallRule -Name "OpenSSH-Server-In-TCP" -ErrorAction SilentlyContinue | Select-Object Name, Enabled)) {
Write-Output "Firewall Rule 'OpenSSH-Server-In-TCP' does not exist, creating it..."
New-NetFirewallRule -Name 'OpenSSH-Server-In-TCP' -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
} else {
Write-Output "Firewall rule 'OpenSSH-Server-In-TCP' has been created and exists."
}
net start sshd # 开启sshd服务
net stop sshd # 关闭sshd服务
5.Windows远程连接程序应用配置完成后打开Xshell远程连接虚拟机即可;
进入Xshell应用程序后:
新建 名称和主机号是你远程连接的ip地址
端口号默认为:22 即ssh端口
协议: ssh
用户身份登录 然后填写远程连接的虚拟机的用户名和用户密码,点击连接即可
显示:
备注:马赛克地方为远程ip地址
***下期是linux的centos如何开启ssh服务***