安裝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