Skip to content

Instantly share code, notes, and snippets.

@allexiusw
Last active February 29, 2020 19:42
Show Gist options
  • Save allexiusw/d00ebaf9af388bcac996927fb89b94e2 to your computer and use it in GitHub Desktop.
Save allexiusw/d00ebaf9af388bcac996927fb89b94e2 to your computer and use it in GitHub Desktop.
SSH Install using Powershell, we also add the ssh directory to the Path environment.
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Write-Host "SSL connections enabled for this session"
Invoke-WebRequest -Uri https://github.com/PowerShell/Win32-OpenSSH/releases/download/v8.1.0.0p1-Beta/OpenSSH-Win64.zip -OutFile openssh-server.zip
Expand-Archive -LiteralPath .\openssh-server.zip -DestinationPath ‘C:\Program Files’
$env:Path += "C:\Program Files\OpenSSH-Win64"
cd "C:\Program Files\OpenSSH-Win64"
.\Install-sshd.ps1
Get-Service | ? Name -like *SSH*
Start-Service sshd
Set-Service -Name sshd -StartupType 'Automatic'
Get-NetFirewallRule -Name *ssh*
New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -PropertyType String -Force
Set-ExecutionPolicy RemoteSigned
Set-ExecutionPolicy Bypass -Scope Process
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
choco install -y vim
choco install -y git
echo $profile
echo "$env:Path += 'C:\Program Files\OpenSSH-Win64'" > $profile
Write-Host "Desde su computadora anfitriona ingrese ssh administrador@IP_SERVER para poder iniciar una sesion remota"
Write-Host "Podra acceder a dos comandos extra choco y git desde el servidor"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment