cmd唤醒windows设置,并配置opsshd
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
最新文章
- 对抗密码破解 —— Web 前端慢 Hash
- 关于在django框架里取已登录用户名字的问题
- java选择排序
- caffe学习系列(4):视觉层介绍
- 字符串—strcpy
- 静态类和静态类成员(C# 编程指南)
- BZOJ2276: [Poi2011]Temperature
- 【项目笔记】布局文件报错Suspicious size: this will make the view invisible, probably intended for layout_width
- UVa1025 (DAG上的dp)
- 展示博客(Beta版本)
- 当前标识没有对“C:\WINDOWS\Microsoft.NET\...”的写访问权限的解决办法
- Windows7 WIN 7 64位 环境编译6sv2.1版本的大气传输模型
- SpringCloud Hystrix
- P3379 【模板】最近公共祖先(LCA)(树链剖分)版
- adb 命令 链接 安装应用
- sql 行变列
- 【LeetCode每天一题】Rotate Image(旋转矩阵)
- 论文笔记:Learning how to Active Learn: A Deep Reinforcement Learning Approach
- centos6.9安装oracle11g
- 将ESXI所有的端口组迁移到分布式交换机的步骤