cmd唤醒windows设置,并配置opsshd

2023-02-15,,,,

1. 从cmd唤起windows设置

这个东西很有意思,大部分在运行窗口输入的内容,从cmd或powershell都能唤起,如:control控制面板,但偶尔有些操作就不能通用,

如:

ms-settings:                        #windows系统设置

win+R唤起运行窗口,输入ms-settings: 后,可以唤起 windosws设置

可,直接从cmd输入后,却只有报错,压根儿就不能唤起 windows设置,这个时候,可以用start ms-settings:

2. 配置opensshd

从windows设置选择应用

或者直接cmd输入 ms-settings:appsfeatures

点击可选功能,搜索是否有:  OpenSSH服务器;没有就从添加功能里去添加,添加的话需要很长时间才能完成

使用管理员角色启服务:net start sshd

设置服务自启动:sc config sshd start= auto

启动服务:net start 服务名
停止服务:net stop 服务名暂停服务:net pause 服务名
恢复被暂停的服务:net continue 服务名
禁用服务:sc config 服务名 start=disabled
将服务设为自动启动:sc config 服务名 start= auto
将服务设为手动启动:sc config 服务名 start= demand 注:
1)服务名不一定是你在服务面板看到的那个名,
例如,你要打开被禁用的telnet服务,sc config telnet start= auto,报错:[SC] OpenService FAILED 1060,因为telnet的服务名不是telnet而是tlntsvr, sc config tlntsvr start= auto 就OK了,
在服务面板里查看telnet属性,从可执行文件的路径里可看到服务程序名,即命令中的服务名。

2)start=后面有空格,少了就有错

参考链接:https://www.cnblogs.com/luofeng99/archive/2011/08/30/2177580.html

验证:

本地登录测试:ssh user@localhost               #注,异机远程登录需要注意防火墙

services.msc 服务管理器查看运行状态和启动类型

纯命令行操作如下(前提,联网):

参考链接:https://learn.microsoft.com/zh-cn/windows-server/administration/openssh/openssh_install_firstuse

1. 联网查包

Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'

2. 安装

# Install the OpenSSH Client
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0 # Install the OpenSSH Server
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0

3. 配置服务启动项

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

4. 设置默认解释器位powershell

New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -PropertyType String -Force

5. 卸载

# Uninstall the OpenSSH Client
Remove-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0 # Uninstall the OpenSSH Server
Remove-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0

cmd唤醒windows设置,并配置opsshd的相关教程结束。

《cmd唤醒windows设置,并配置opsshd.doc》

下载本文的Word格式文档,以方便收藏与打印。