check if is admin
(New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
# Start the sshd service
Start-Service sshd
# OPTIONAL but recommended:
Set-Service -Name sshd -StartupType 'Automatic'
# 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."
}
Get-Service -Name sshd
Get-NetFirewallRule -Name *ssh*
netstat -ant
whoami
sshd_config
AuthenticationMethods
Available authentication methods are password
and publickey
.
AuthorizedKeysFile
The default is
.ssh/authorized_keys
.ssh/authorized_keys2
If the path is not absolute, it is taken relative to user's home directory (or profile image path).
Ex. c:\users\user.
From v7.7.2.2 on wards, following is the default location of AuthorizedKeysFile for all users in Administrators group
%programdata%/ssh/administrators_authorized_keys
https://github.com/PowerShell/Win32-OpenSSH/wiki/sshd_config
https://learn.microsoft.com/en-us/windows-server/administration/openssh/openssh_server_configuration
https://learn.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse
标签:sshd,Name,openssh,TCP,Server,OpenSSH,win From: https://www.cnblogs.com/Searchor/p/17391068.html