我可以從 Linux shell 連線到 Windows 機器嗎?

我可以從 Linux shell 連線到 Windows 機器嗎?

我可以使用 PuTTY/SSH 從 Windows 連線到 Linux 電腦。我想做相反的事情 - 從 Linux 連接到 Windows 機器。

這可能嗎?

答案1

這取決於您想要如何連接。您可以在 Windows 電腦上建立共用並使用 smb/cifs 連接到共用。

語法取決於您是否在網域中。

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

您也可以安裝$IPC管理共用。您可以查看進程間通信,以了解可以透過共用執行哪些操作$IPC

總有:

  • 遠端開發計劃
  • 虛擬網路控制器
  • 遠端登入
  • SSH
  • Windows 上的 Linux

後 3 個,您需要安裝其他軟體。

VNC 可以從獨立的二進位檔案運行,也可以安裝。

對於 RDP,大多數 Linux 系統要么已經rdesktop安裝,要么在套件管理器中可用。使用時,rdesktop您只需啟用與 Windows 系統的 RDP 連接,然後您就可以將 RDP 用於完整的 GUI Windows 控制台。

答案2

如果您處於開啟狀態Windows 10,則可以OpenSSH使用下列 Powershell 腳本進行安裝。

#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

請注意,此腳本會將 dns 變更為 Google dns。因為 OpenSSH沒有隨預設Windows10發行版一起分發,所以它實際上會從網路上下載一些檔案。因此,您需要一個有效的互聯網連接和一個正確的 dns 伺服器,這就是我指定靜態 dns 伺服器的原因,以防萬一您位於防火牆後面或使用沒有 dns 伺服器的靜態 ip。

完成此操作後,您應該找出Windows 主機的 IP 位址

ipconfig

然後從Linux/Unix作業系統做

ssh username@Windows_ip

其中 username 是帳戶名稱,Windows_ip是您嘗試登入的 Windows 電腦的 IP 位址

答案3

是的,您可以從 Linux 用戶端連接到 Windows 電腦。但為此,您必須在 Windows 電腦上託管某種類型的伺服器(即 telnet、ssh、ftp 或任何其他類型的伺服器),並且您應該在 Linux 上擁有相應的用戶端。

答案4

如果你在 Windows 上使用 git,恭喜你,你已經可以 ssh 進入你的 Windows 機器了。

只需啟動 ssh 伺服器:

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

然後使用以下 powershell 指令設定防火牆:

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

相關內容