From 565c45febe0f89c323760b2155eb253b87c1f694 Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Thu, 25 Mar 2021 17:24:31 +0100 Subject: [PATCH] Add enable-ssh-server.ps1 --- Data/scripts.csv | 1 + README.md | 1 + Scripts/enable-ssh-server.ps1 | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+) create mode 100755 Scripts/enable-ssh-server.ps1 diff --git a/Data/scripts.csv b/Data/scripts.csv index 8f22d26f..9a79ec18 100644 --- a/Data/scripts.csv +++ b/Data/scripts.csv @@ -34,6 +34,7 @@ display-time.ps1, displays the current time for 10 seconds by default download.ps1, downloads the file/directory from the given URL enable-crash-dumps.ps1, enables the writing of crash dumps enable-god-mode.ps1, enables the god mode (adds a new icon to the desktop) +enable-ssh-server.ps1, enables the SSH server encrypt-file.ps1, encrypts the given file fetch-repo.ps1, fetches updates for the current/given Git repository (including submodules) fetch-repos.ps1, fetches updates for all Git repositories under the current/given directory (including submodules) diff --git a/README.md b/README.md index 14b51b98..6c283ad9 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,7 @@ Mega Collection of PowerShell Scripts * [check-swap-space.ps1](Scripts/check-swap-space.ps1) - checks the swap space for free space left * [check-windows-system-files.ps1](Scripts/check-windows-system-files.ps1) - checks the validity of the Windows system files (requires admin rights) * [enable-crash-dumps.ps1](Scripts/enable-crash-dumps.ps1) - enables the writing of crash dumps +* [enable-ssh-server.ps1](Scripts/enable-ssh-server.ps1) - enables the SSH server * [hibernate.ps1](Scripts/hibernate.ps1) - enables hibernate mode for the local computer (requires admin rights) * [list-drives.ps1](Scripts/list-drives.ps1) - lists all drives * [list-network-shares.ps1](Scripts/list-network-shares.ps1) - lists the network shares of the local computer diff --git a/Scripts/enable-ssh-server.ps1 b/Scripts/enable-ssh-server.ps1 new file mode 100755 index 00000000..56517270 --- /dev/null +++ b/Scripts/enable-ssh-server.ps1 @@ -0,0 +1,19 @@ +#!/bin/powershell +<# +.SYNTAX ./enable-ssh-server.ps1 +.DESCRIPTION enables the SSH server +.LINK https://github.com/fleschutz/PowerShell +.NOTES Author: Markus Fleschutz / License: CC0 +#> + +try { + Add-WindowsCapability -Online -Name OpenSSH.Server* + Start-Service sshd + Set-Service -Name sshd -StartupType 'Automatic' + + write-host -foregroundColor green "OK - SSH server enabled" + exit 0 +} catch { + write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +}