Connecting to Linux Host from Windows Host

Hello Team I am totally new to Ansible and I have got one task like this
Connect to a Windows server-----> from the windows server connect to a linux server via the ssh key I have manually tested this is possible but this entire connection setup is now to be done via ansible can anyone please help me how to do this ? I have researched quite a lot and found that in my local pywinrm module needs to be installed and use the ansible_winrm module to establish connection to the windows server but from windows to linux server I am not getting any clue please note the windows server is the intermediatary server and ansible cannot be installed on the server

Hello @adrijatina,

Let’s see if I got it straight; what you want to do is to use your windows server as a jump host in order to deploy or configure a Linux server that is out of reach from your local machine?

If that’s so, you need to be aware that Ansible does not run natively on windows. I mean, you need to use WSL2 (preferably) along with a Linux VM (e.g. Ubuntu, Fedora, etc) on your win server to execute Ansible. Then, from within WSL you could enable an ssh-server so the Linux VM can perform the connection to the target Linux server (that is- the WSL Linux VM acts as the jump host here). However, as far as I know this approach is not quite stable , but there are workarounds for that- you may set the ssh server on windows and then use WSL as the default shell, as suggested on this blog post:

Then, on your local machine you also need to set an specific ssh configuration on ~/.ssh/config, so the connection gets tunneled through the jump host.

I suggest you to catch a glimpse to this piece of documentation, which may be of use to you, too:

If anyone else knows a better way to stablish a windows based jump host, it may be good to know :slight_smile:

Hope it helps!