【Vscode】解决 An SSH installation couldn‘t be found

【Vscode】解决 An SSH installation couldn‘t be found

背景描述:在vscode中使用ssh进行连接到时候,已经安装了ssh romote的plugin插件,但是在输入了ssh连接命令之后,仍然出现报错:an ssh installation could not be found vscode,本文进行讲解并且给出解决办法。(操作系统windows10)

首先:需要理清楚先后关系;
在windows上使用vscode用ssh来连接远程服务器是需要powershell来进行设置ssh client和ssh server的,需要保证这两个应用安装成功,才能够允许vscode的插件来调用操作系统的服务。

因此首先需要做的就是检查是否成功安装了上述的两个应用:

首先打开powershell(windows+q)输入powershell,并且输入以下命令:

Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'

这个命令会输出一下内容:
【Vscode】解决 An SSH installation couldn‘t be found_第1张图片

注意:
如果出现两个内容都是“NotPresent”, 这样就说明你没有安装任何两个应用,所以需要进行安装:
下面两个命令 便可以进行安装:

# 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

(安装过程中会以小圆圈的形式来表示进度条),第一个安装比较快,第二个会稍微慢一些,尤其注意:建议在安装之前一定要以管理员身份打开poweshell,不然一般会在第二个Server安装的时候出现问题。

安装成功之后(配置):
依次输出下面三步命令:

# 1. Start the sshd service
Start-Service sshd

# 2. OPTIONAL but recommended:
Set-Service -Name sshd -StartupType 'Automatic'

# 3. 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."
}

这样之后,你就可以进行测试:

ssh {yourusername}@{servername} -p {your port} 

一般来说这样就可以成功安装!

respect!!!

你可能感兴趣的:(vscode,ssh,ide)