windows 2008 r2 x64 离线升级PowerShell3.0 及打开WinRM模块并安装openssh

  1. bat脚本
echo off
set apath=%~dp0
:: 如果运行提示找不到文件apath 写完整路径
echo "install net4.0"
%apath%\dotNetFx45_Full_x86_x64.exe  /quiet /norestart
start /w pkgmgr /iu:PowerShell
echo y|powershell set-executionpolicy remotesigned
echo "PowerShell 3.0"
%apath%\Windows6.1-KB2506143-x64.msu  -ArgumentList /quiet 
REG add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run"  /v "ansible" /t REG_SZ /d "\"%apath%Powerl.bat\"" /f
echo PowerShell %apath%\ConfigureRemotingForAnsible.ps1>%apath%Powerl.bat
echo REG DELETE "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /v "ansible" /f >>%apath%Powerl.bat 
pause

离线升级包下载地址:

链接:http://pan.baidu.com/s/1dE2h9aL 密码:jd7j

安装完成需要重启服务器。

 2. 查看powershell版本

PS C:\> $PSVersionTable

 

 3 然后即可安装openssh

  1. 下载最新的 OpenSSH (github.com),并解压到C:\Program Files\OpenSSH
  2. 安装openssh
cd "C:\Program Files\OpenSSH"
powershell.exe -ExecutionPolicy Bypass -File install-sshd.ps1
  1. 设置 Firewalld
New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
# 如果 win7/win2008 执行上面的命令报错请执行此处的命令 netsh advfirewall firewall add rule name=sshd dir=in action=allow protocol=TCP localport=22
 
  1. 启动 OpenSSH
net start sshd Set-Service sshd -StartupType Automatic

 


 

posted @ 2022-06-28 15:26  ITer的运维人生  阅读(296)  评论(0编辑  收藏  举报