paramiko连接windows10详解,远程管理windows服务器
1、win10安装 OpenSSH
官网链接:https://docs.microsoft.com/zh-cn/windows-server/administration/openssh/openssh_install_firstuse
按住shift键,在某个目录点击鼠标右键,点击打开powershell

1、安装软件 # 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 2、启动软件 # 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. Get-NetFirewallRule -Name *ssh* # There should be a firewall rule named "OpenSSH-Server-In-TCP", which should be enabled # If the firewall does not exist, create one New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22 3、卸载软件 # 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
2、连接windows程序
import paramiko ssh = paramiko.SSHClient() ssh.load_system_host_keys() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect('192.168.*.*',port = 22, username='ADMINISTRATOR',password='****') print ("Connected to %s" % '192.168.*.*') stdin, stdout, stderr = ssh.exec_command('dir d:') aa=stdout.read() bb=stderr.read() print(aa.decode('gbk')) print('==========================') print(bb.decode('gbk'))
3、执行cmd命令,如开启服务
4、运行wmic命令
windows cmd命令学习:https://www.cnblogs.com/machangwei-8/p/10859951.html
ip='127.0.0.1'
ssh.connect(ip,port = 22, username='ADMINISTRATOR',password='m1xxx')
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· 什么是nginx的强缓存和协商缓存
· 一文读懂知识蒸馏
· Manus爆火,是硬核还是营销?
2018-09-01 unzip/tar命令详解
2018-09-01 tar命令详解
2018-09-01 tee命令详解
2018-09-01 vi/vim命令详解
2018-09-01 tr命令详解
2018-09-01 join命令详解
2018-09-01 rev命令详解