87

I can connect to Linux machines from Windows using PuTTY/SSH. I want to do the other way round - connect to a Windows machine from Linux.

Is this possible?

3
  • See answer below: unix.stackexchange.com/a/427739/242983. OpenSSH is now supported natively by the latest update of Windows10. However, its not available for older versions. Please update your Windows10 before trying this.
    – alpha_989
    Mar 2, 2018 at 18:20
  • @Manishearth Because sometimes you just want something that works out of the box with no extra reading required.
    – Zimano
    May 1, 2019 at 13:21
  • Also suggestion from pypi.org/project/pypsexec can help to execute remote windows commands Feb 26, 2021 at 6:51

8 Answers 8

32

It depends on how you want to connect. You can create shares on the Windows machine and use smb/cifs to connect to the share.

The syntax would depend based on if you are in a domain or not.

# mount -t cifs //server/share /mnt/server --verbose -o user=UserName,dom=DOMAIN

You also have the ability to mount the $IPC and administrative shares. You can look into Inter-Process Communication for what you can do via the $IPC share.

There is always:

  • RDP
  • VNC
  • telnet
  • ssh
  • Linux on Windows

With the last 3 you need to install additional software.

VNC can be run from a stand-alone binary or installed.

For RDP most Linux systems either already have rdesktop installed or it is available in the package manager. Using rdesktop you only have to enable RDP connections to your Windows system and then you will be able to use RDP for a full GUI Windows console.

10

If you are on Windows 10, you can install OpenSSH using the following Powershell script.

#change dns server to 8.8.8.8 so that the OpenSSH stuff can be downloaded
netsh interface ip set dns "Ethernet" static 8.8.8.8

#sleep for 60 s so that the DNS server has time to register
Start-Sleep -m 60

#check if OpenSSH is already installed or not
Get-WindowsCapability -Online | ? 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

# Check if OpenSSH is available
dism /Online /Get-Capabilities | findstr OpenSSH

# install the server and/or client features:
dism /Online /Add-Capability /CapabilityName:OpenSSH.Client~~~~0.0.1.0
dism /Online /Add-Capability /CapabilityName:OpenSSH.Server~~~~0.0.1.0

Install-Module -Force OpenSSHUtils

Repair-SshdHostKeyPermission -FilePath C:\Windows\System32\OpenSSH\ssh_host_ed25519_key

# start the ssh server daemon
Start-Service sshd

# This should return a Status of Running
Get-Service sshd

# add firewall rule to allow inbound and outbound traffic through port 22
New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Service sshd -Enabled True -Direction Inbound -Protocol TCP -Action Allow -Profile Domain

Please note that this script will change the dns to Google dns. Because OpenSSH is not distributed with the default Windows10 distribution, it will actually download some files from the internet. So you need a working internet connection and a correct dns server, which is why I specified the static dns server, just in case you are behind a firewall or using a static ip with no dns server.

Once you have done this, you should figure out the ip address of the Windows host usign

ipconfig

Then from the Linux/Unix OS do

ssh username@Windows_ip

where username is the name of the account and Windows_ip is the ip address of the Windows computer you are trying to log into

4
  • On my windows installation, nothing except the first line is run. The response is "Sart-Sleep is not recognized as an internal or external command, operable program or batch file". So this is not quite as cookie-cutter as you'd like :-)
    – levitopher
    Dec 10, 2018 at 20:54
  • 1
    An anonymous user has just noted in a (failed) edit that the line starting with Repair-SshdHostKeyPermission is not needed. I don't know whether or not this is true, but in case it is I don't want the note lost forever.
    – roaima
    Feb 5, 2019 at 23:30
  • Powershell should be open in administrator mode
    – alper
    Oct 15, 2020 at 14:53
  • I am having following error: No match was found for the specified search criteria and module name 'OpenSSHUtils'. I am also having following error when I try to connect into it : Unable to negotiate with 192.168.137.1 port 22: no matching host key type found. Their offer: ssh-dss
    – alper
    Oct 15, 2020 at 15:24
7

Yes, you can connect to Windows Machine from Linux client. But for that you have to host some kind of server(i.e. telnet, ssh, ftp or any other kind of server) on Windows machine and you should have the corresponding client on the Linux.

6
  • 3
    Since Windows is more dependent on its GUI than Linux, your best bet is probably RDP.
    – cjm
    Mar 24, 2012 at 18:55
  • I don't think something like ftp was meant in the question. And telnet - ... really? Mar 24, 2012 at 22:41
  • 1
    Yeah, he probably meant ssh...
    – jcora
    Mar 25, 2012 at 8:44
  • @pradeepchhetri and does Windows have some of this servers active by default?
    – H_7
    Mar 25, 2012 at 15:22
  • 3
    @H_7: Windows supports telnet and ftp server but by default they are not running. You have to make them run by: 1. Go to Control Panel -> 2. Programs And Features -> 3. Turn Windows features on or off. Here you can see the list of servers or client. You can run telnet or ftp server from here. Mar 25, 2012 at 15:38
7

Maybe you would like to give RDP or software like teamviewer a try. Also you could install cygwin on your windows machine and configure it for ssh access, so you'd get a shell as you know it from linux when you connect by ssh.

5

If you use git on windows, congratulations, you can already ssh into your windows machine.

Just start the ssh server:

net start "C:\Program Files\Git\usr\bin\sshd.exe"

Then configure your firewall with this powershell command:

New-NetFirewallRule -Name sshd -DisplayName 'SSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
2

You should install openssh server on Windows Machine like openssh server on android.You can use putty on iinux machine to ssh to windows Machine.You can use netstat to check it after you can install openssh server on windows machine.

1
  • 6
    why do you need putty on linux machines to ssh to windows? ssh it typically already installed on linux machines.. isnt it?
    – alpha_989
    Mar 2, 2018 at 18:05
1

I had this same issue tyring to ssh into a Windows server from my Ubuntu 18.04 machine.

If you are a Ubuntu user, you could try out Remmina.

It comes bundled with most Ubuntu distributions.

That's all.

I hope this helps

0

You can create an OpenSSH server on the windows machine, start the server and whola!

Read these for reference:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.