Private/Wissen/X_Technology/X22_Linux.ps1
<#
# Linux PowerShell und Linux - **Hashtags** Linux Remote Ubuntu - **Version** 2020.01.17 #> # On Windows 10 # https://docs.microsoft.com/de-de/windows-server/administration/openssh/openssh_install_firstuse Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*' Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0 Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0 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* # 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 Ssh alex@AlexUbuntuVM # On Ubuntu Linux 18.10 # 1. PowerShell installieren # 2. sudo apt install openssh-client sudo apt install openssh-server # https://docs.microsoft.com/de-de/powershell/scripting/learn/remoting/ssh-remoting-in-powershell-core?view=powershell-7 New-PSSession -HostName AlexUbuntuVM -UserName alex # P@ssw0rd #region Linux on Hyper-V $ErrorActionPreference = "Stop" Remove-VM "Ubuntu" -Force Remove-Item -Path 'C:\Hyper-V\Virtual Harddisks\Ubuntu.vhdx' -Force $newVhd = @{ Path = 'C:\Hyper-V\Virtual Harddisks\Ubuntu.vhdx' SizeBytes = 100GB Dynamic = $true BlockSizeBytes = 1MB } New-VHD @newVhd $newVm = @{ Name = "Ubuntu" MemoryStartupBytes = 4GB SwitchName = "Default Switch" VHDPath = 'C:\Hyper-V\Virtual Harddisks\Ubuntu.vhdx' Generation = 2 Force = $true } New-VM @newVm $setVm = @{ Name = "Ubuntu" ProcessorCount = 4 DynamicMemory = $true CheckpointType = "Disabled" AutomaticCheckpointsEnabled = $false } Set-VM @setVm $addVMDvdDrive = @{ VMName = "Ubuntu" Path = "C:\Temp\ubuntu-19.10-desktop-amd64.iso" Passthru = $true } $firstBootDevice = Add-VMDvdDrive @addVMDvdDrive $setVMFirmware = @{ VMName = "Ubuntu" EnableSecureBoot = "Off" FirstBootDevice = $firstBootDevice } Set-VMFirmware @setVMFirmware $enableVMIntegrationService = @{ VMName = "Ubuntu" Name = "Gastdienstschnittstelle" } Enable-VMIntegrationService @enableVMIntegrationService Start-VM -Name "Ubuntu" #endregion |