Vim for remote Windows

Our development team is constantly improving the RUDDER software. They have to be at the cutting edge of technology. So they give you tips and feedbacks on the codes and techniques they use when they discover something interesting.
Here, Felix explains how you can use SSH and Vim to edit Powershell script directly in Windows systems.

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.

Next step, be able to run Powershell commands and edit remote files.

Powershell as default SSH shell

The SSH server runs cmd.exe as default shell, it can be changed via a registry entry.

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.

From Windows to Linux:
From Linux to Windows:
And now if I want to edit remote files:
But I was unable to find a syntax working for path using spaces, I tried a bunch of different potential syntaxes, none were working. As an ugly workaround, I ended up defining a Joined folder to link the Rudder folder to one without any space in its path.

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 fda@rudder.io

Félix Dallidet
Our development team is constantly improving the RUDDER software. They have to be at the cutting edge of technology. So they give you tips and feedbacks on the codes and techniques they use when they discover something interesting.
Here, Felix explains how you can use SSH and Vim to edit Powershell script directly in Windows systems.

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.

Next step, be able to run Powershell commands and edit remote files.

Powershell as default SSH shell

The SSH server runs cmd.exe as default shell, it can be changed via a registry entry.

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.

From Windows to Linux:
From Linux to Windows:
And now if I want to edit remote files:
But I was unable to find a syntax working for path using spaces, I tried a bunch of different potential syntaxes, none were working. As an ugly workaround, I ended up defining a Joined folder to link the Rudder folder to one without any space in its path.

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 fda@rudder.io

Félix Dallidet

Partager ce post

Retour en haut
Rudder robot named Ruddy makes an announcement.

Rudder 8.2 : simplifiez la conformité de la sécurité IT avec la solution Policy and benchmark

Détails du module Security management

Ce module a pour objectif de garantir une sécurité et une conformité optimales pour la gestion de votre infrastructure, avec des fonctionnalités pour les entreprises telles que :

Pour en savoir plus sur ce module, consultez la page gestion de la sécurité.

Détails du module configuration & patch management

Ce module vise une performance et une fiabilité optimales pour la gestion de votre infrastructure et de vos patchs, avec des fonctionnalités pour les entreprises telles que :

Pour en savoir plus sur ce module, consultez la page gestion des configurations et des patchs.