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
最新文章
- sz rz SecureCRT
- Python自动化之django视图
- iOS开发-- RunLoop的基本概念与例子分析
- HDU-4089 Activation (概率DP求概率)
- R语言串行与并行Apply用法
- 使用Application_Error捕获站点错误并写日志
- .NET Core 2.0 Preview2 发布汇总
- Abp异常-找不到方法:“System.String Abp.Runtime.Security.SimpleStringCipher.Decrypt(System.String, System.String, Byte[])”
- Python(五) —— 内置模块
- spring jdbcTemplate 事务,各种诡异,包你醍醐灌顶!
- C# 生成编号(防并发)
- 快速入门Splay
- vue 父子组件的方法调用
- shell for 循环数组
- MT【96】一道三角恒等变换题
- iOS开发-Certificates、Identifiers和Profiles详解
- C#或Python中正则表达式元字符含意
- [Openwrt 项目开发笔记]:Openwrt平台搭建(一)补遗
- WPF性能调试系列 – Ants Performance Profiler
- 设计模式--观察者模式C++实现