ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

Windows安装OpenSSH的注意点

2021-11-27 22:01:25  阅读:174  来源: 互联网

标签:exe Name Windows OpenSSH TCP Server 安装 SOFTWARE


1、坚信Windows自带的OpenSSH是比较好用的

  • 关注微软官方文档会事半功倍,请看链接OpenSSH入门
  • 相信大部分错误其实跟配置文件sshd_config没多大关系

补充一个防火墙规格的shell脚本,便于复制。

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

2、解决问题过程中遇到的问题

​ (1) ssh克隆windows仓库的地址命名规则

#git clone 用户名@主机地址或主机名:具体的仓库地址
#用户名为windows用户名,可在windows设置功能中新增git用户
#主机地址为IP地址或者主机名
#仓库地址若在D盘test文件夹,则需要用/d/test,而不是D:/test
#否则报找不到仓库的错误
Please make sure you have the correct access rights
and the repository exists.

​ (2) 配置OpenSSH默认使用的shell

# 注意bash.exe的路径使用你自己的
New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value "C:\Program Files\Git\bin\bash.exe" -PropertyType String -Force

DefaultShell : C:\linxy\software\git\Git\bin\bash.exe
PSPath       : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\OpenSSH
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE
PSChildName  : OpenSSH
PSDrive      : HKLM
PSProvider   : Microsoft.PowerShell.Core\Registry
# 注意powershell.exe使用你自己的
New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -PropertyType String -Force

还原shell也可以参考官网信息

标签:exe,Name,Windows,OpenSSH,TCP,Server,安装,SOFTWARE
来源: https://www.cnblogs.com/boydenyol/p/15613237.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有