windows sshd powershell 配置
安装sshd
打开“设置”,选择“应用”>“应用和功能”,然后选择“可选功能” 。
扫描列表,查看是否已安装 OpenSSH。 如果未安装,请在页面顶部选择“添加功能”,然后:
查找“OpenSSH 客户端”,再单击“安装”
查找“OpenSSH 服务器”,再单击“安装”
开启sshd服务
# Start the sshd service
Start-Service sshd
# OPTIONAL but recommended:
Set-Service -Name sshd -StartupType 'Automatic'
免密登录:
服务端切换到C:\ProgramData\ssh\下(首次启动sshd后会生成该文件夹),打开sshd_config文件,
修改文件(以下是重点):
确保以下3条没有被注释
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
PasswordAuthentication no
确保以下2条有注释掉 重点,这两行要注释
#Match Group administrators
# AuthorizedKeysFile __PROGRAMDATA__/ssh/administrators_authorized_keys
相关命令:
查看状态:Get-Service sshd
关闭服务:Stop-Service sshd
重启服务:Restart-Service sshd
为 Win10 的 OpenSSH 配置默认 shell:
先确认 OpenSSH 默认安装位置是:C:Windows\System32\openssh 。
cmd 中 path 和 PowerShell 中 $env:path 可以显示当前路径。
在 PowerShell 中用以下命令将默认 shell 设为 PowerShell:
New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -PropertyType String -Force
powerShell 配置
安装需要的软件
Install-Module -AllowClobber Get-ChildItemColor
choco install ntop.portable
查看profile
$PROFILE
编辑profile 内容如下
set-alias vi "C:/Program Files (x86)/Vim/vim82/./vim.exe"
set-alias git "C:/Program Files/Git/bin/./git.exe"
set-alias top "C:/ProgramData/chocolatey/bin/ntop.exe"
Import-Module PSReadLine
If (-Not (Test-Path Variable:PSise)) {
# Only run this in the console and not in the ISE
Import-Module Get-ChildItemColor
Set-Alias l Get-ChildItem -option AllScope
Set-Alias ls Get-ChildItemColorFormatWide -option AllScope
}
# Shows navigable menu of all options when hitting Tab
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete
# Autocompletion for arrow keys
Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward
New-Alias open invoke-item
New-Alias which get-command
引用链接
https://zhuanlan.zhihu.com/p/356463854
https://docs.microsoft.com/zh-cn/windows-server/administration/openssh/openssh_install_firstuse
https://www.cnblogs.com/deepinnet/p/15228378.html
https://ld246.com/article/1598698273711
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?