VSCode SSH - Allows using VSCode to build code as if you were on remote machine. - Remote machine will still need dotnet SDK Added AppSetting Markdown
4.6 KiB
4.6 KiB
VSCode SSH
- Allows using VSCode to build code as if you were on remote machine.
- Remote machine will still need dotnet SDK
Offline Installer
-
Download and copy to servers that can't reach github.com
PowerShell Installer
- PowerShell Administrator
Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'
# Install the OpenSSH Client
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
# Install the OpenSSH Server
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
Key Generation
- Run with any user
ssh-keygen -t ed25519
Authentication via Public Key
- PowerShell Administrator
copy $env:USERPROFILE\.ssh\id_ed25519.pub C:\ProgramData\ssh\authorized_keys
copy $env:USERPROFILE\.ssh\id_ed25519.pub C:\ProgramData\ssh\administrators_authorized_keys
icacls.exe "C:\ProgramData\ssh\authorized_keys" /inheritance:r /grant "Administrators:F" /grant "SYSTEM:F"
icacls.exe "C:\ProgramData\ssh\administrators_authorized_keys" /inheritance:r /grant "Administrators:F" /grant "SYSTEM:F"
- Configuration allows for public key authentication
- Removes higher risk password authentication
...
PubkeyAuthentication yes
...
PasswordAuthentication no
...
Firewall
- Open Windows Firewall with Advanced Security GUI
- Add new Inbound Rule for port 22
- Change Profiles to only enable domain
- Change scope to remote ip for your machine
wf.msc
- Exported list for the two inbound rules
Name Group Profile Enabled Action Override Program Local Address Remote Address Protocol Local Port Remote Port Authorized Users Authorized Computers Authorized Local Principals Local User Owner Application Package
OpenSSH SSH Server Preview (sshd) Private Yes Allow No C:\Program Files\OpenSSH\sshd.exe Any Any TCP 22 Any Any Any Any Any Any
SSH Domain Yes Allow No Any Any 10.64.233.125 TCP 22 Any Any Any Any Any Any
- Command line add inbound rule SSH
netsh advfirewall firewall add rule name="SSH" dir=in action=allow enable=yes profile=domain remoteip=10.64.233.125 localport=22 protocol=TCP
- Command line to add remote IP
netsh advfirewall firewall set rule name="SSH" new remoteip=10.64.233.125
- Command line to enable rule
netsh advfirewall firewall set rule name="SSH" new enable=yes
Local Key Generation
- Replace user
- Run on local machine
- Add output to remote machine
ssh-keygen -t ed25519
more "C:/Users/user/.ssh/id_ed25519.pub"
echo "C:\ProgramData\ssh\authorized_keys"
echo "C:\ProgramData\ssh\administrators_authorized_keys"
Test Connection
- Replace user and machine
ssh user@machine.infineon.com -i C:/Users/user/.ssh/id_ed25519
VSCode
- Install VSCode extension ms-vscode-remote.remote-ssh
- Add machine to VSCode Remote Explorer
- Example after adding machine to Remote Explorer "C:\Users\phares.ssh\config"
Host mestsa003.infineon.com
HostName mestsa003.infineon.com
User mesphares
IdentityFile C:/Users/phares/.ssh/id_ed25519
Host mestsa05ec.infineon.com
HostName mestsa05ec.infineon.com
User mesphares
IdentityFile C:/Users/phares/.ssh/id_ed25519
Host mestsa07ec.infineon.com
HostName mestsa07ec.infineon.com
User mesphares
IdentityFile C:/Users/phares/.ssh/id_ed25519
Host messa010ec.infineon.com
HostName messa010ec.infineon.com
User mesphares
IdentityFile C:/Users/phares/.ssh/id_ed25519