Can I connect to Windows machine from Linux shell?

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.

  • Kpym (telnet / ssh server)
  • MobaSSH (ssh server)
  • Cygwin (run a Linux environment inside Windows)
  • DamnSmall Linux - inside Windows (like Cygwin run DSL inside Windows)

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

  • RealVNC
  • TightVNC

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.


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


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.

Tags:

Windows

Linux

Ssh