PowerShell: Difference between revisions
Jump to navigation
Jump to search
Line 10: | Line 10: | ||
Invoke-Command -ComputerName 10.19.83.10 -ScriptBlock { Get-ChildItem C:\ } -Credential academia | Invoke-Command -ComputerName 10.19.83.10 -ScriptBlock { Get-ChildItem C:\ } -Credential academia | ||
Enter-PSSession -ComputerName 10.19.83.10 -Credential academia | Enter-PSSession -ComputerName 10.19.83.10 -Credential academia | ||
</source> | |||
==OpenSSH== | |||
<source lang="powershell"> | |||
Get-WindowsCapability -Online | ? Name -like 'OpenSSH*' | |||
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0 | |||
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0 | |||
</source> | |||
<source lang="powershell"> | |||
dism /Online /Get-Capabilities | findstr OpenSSH | |||
dism /Online /Add-Capability /CapabilityName:OpenSSH.Client~~~~0.0.1.0 | |||
dism /Online /Add-Capability /CapabilityName:OpenSSH.Server~~~~0.0.1.0 | |||
</source> | |||
<source lang="powershell"> | |||
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 | |||
</source> | |||
<source lang="bat"> | |||
notepad++ %PROGRAMDATA%\ssh\sshd_config | |||
</source> | |||
<source lang="ini" highlight="1,18" start="34" line> | |||
PubkeyAuthentication yes | |||
# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2 | |||
# but this is overridden so installations will only check .ssh/authorized_keys | |||
AuthorizedKeysFile .ssh/authorized_keys | |||
#AuthorizedPrincipalsFile none | |||
# For this to work you will also need host keys in %programData%/ssh/ssh_known_hosts | |||
#HostbasedAuthentication no | |||
# Change to yes if you don't trust ~/.ssh/known_hosts for | |||
# HostbasedAuthentication | |||
#IgnoreUserKnownHosts no | |||
# Don't read the user's ~/.rhosts and ~/.shosts files | |||
#IgnoreRhosts yes | |||
# To disable tunneled clear text passwords, change to no here! | |||
PasswordAuthentication yes | |||
#PermitEmptyPasswords no | |||
</source> | </source> | ||
Revision as of 20:59, 21 November 2020
Get-Service WinRM
Restart-Service WinRM
Enable-PSRemoting -Force
Set-Item WSMan:\localhost\Client\TrustedHosts *
WinRM s winrm/config/client '@{TrustedHosts="10.19.83.10,10.19.83.14"}'
WinRM quickconfig
Test-WsMan 10.19.83.10
Invoke-Command -ComputerName 10.19.83.10 -ScriptBlock { Get-ChildItem C:\ } -Credential academia
Enter-PSSession -ComputerName 10.19.83.10 -Credential academia
OpenSSH
Get-WindowsCapability -Online | ? Name -like 'OpenSSH*'
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
dism /Online /Get-Capabilities | findstr OpenSSH
dism /Online /Add-Capability /CapabilityName:OpenSSH.Client~~~~0.0.1.0
dism /Online /Add-Capability /CapabilityName:OpenSSH.Server~~~~0.0.1.0
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
notepad++ %PROGRAMDATA%\ssh\sshd_config
PubkeyAuthentication yes
# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
# but this is overridden so installations will only check .ssh/authorized_keys
AuthorizedKeysFile .ssh/authorized_keys
#AuthorizedPrincipalsFile none
# For this to work you will also need host keys in %programData%/ssh/ssh_known_hosts
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes
# To disable tunneled clear text passwords, change to no here!
PasswordAuthentication yes
#PermitEmptyPasswords no
Knowledge
Get-Service WinRM
Restart-Service WinRM
Enable-PSRemoting -Force
Get-Item WSMan:\localhost\Client\TrustedHosts
Set-Item WSMan:\localhost\Client\TrustedHosts *
Set-Item WSMan:\localhost\Client\TrustedHosts -Force -Value 10.19.83.10
$s = New-PSSession -ComputerName "10.19.83.10" -Credential(Get-Credential)
Invoke-Command -Session $s -ScriptBlock { Get-ChildItem C:\ }
Invoke-Command -Session $s -ScriptBlock { Get-Service }
Get-NetConnectionProfile
Set-NetConnectionProfile -InterfaceIndex 10 -NetworkCategory Private
Set-WSManQuickConfig
Enable-PSRemoting -SkipNetworkProfileCheck
Get-NetConnectionProfile | Set-NetConnectionProfile -NetworkCategory Private
brew cask install powershell
brew upgrade powershell --cask
brew tap homebrew/cask-versions