Since Windows 10, Windows is shipped with an optional built-in OpenSSH server.
This is a great news, since I am used to dev on my Linux environment and with this built-in SSH server, I should be able to keep my daily tools (a shell and the Vim editor) to get the work done on my servers.
Configuring the SSH access was pretty easy, by default the password and key authentification are enabled, creating a .ssh/authorized_keys under my user home on the Windows machine was enough for my needs.
Powershell as default SSH shell
The SSH server runs cmd.exe as default shell, it can be changed via a registry entry.
# To get the powershell default path (Get-Command -name powershell.exe).Path # To set it as default SSH shell Set-Itemproperty -path 'HKLM:\SOFTWARE\OpenSSH' -Name 'DefaultShell' -value (Get-Command -name powershell.exe).Path
Remote file edition using vim
Vim comes with a feature to edit remote file using SCP. The syntax is described there.
But the issue here is that Windows and Linux are using different path syntaxes and escaping methods.
Below are the different syntaxes that I ended up with when trying to access my remote files.
# Copy "C:\my_folder\my_file" to the local folder scp -P2209 email@example.com:/my_folder/my_file . # Copy "C:\Program Files/Rudder/policy/rudder.ps1" to the local folder # The space make it quite hard, I could not find any method without the -T option scp -T -P2209 firstname.lastname@example.org:\"/Program\ Files/Rudder/policy/rudder.ps1\" .
# Copy my_file to "C:\my_folder\my_file" scp -P2209 my_file email@example.com:"C:/my_folder/" # Copy my_file to "C:\Program Files\Rudder\" scp -P2209 my_file 'firstname.lastname@example.org:"C:/Program Files/Rudder/"'
# Trivial if there is no spaces vim scp://email@example.com:2209//my_folder/my_file
# In cmd.exe to create the link mklink /J "Rudder" "C:\Program Files\Rudder" # I can now access my files using vim scp://firstname.lastname@example.org:2209//Rudder/policy/rudder.ps1
There are most likely better ways to achieve this but still, I was quite happy to not have to use anymore remote desktop UI tools nor shared folders to work on my Windows dev machines.
If you have anything better, feel free to send me an email at email@example.com