Windows SCP命令與Ubuntu連接

實驗環境:

  1. Windows平臺:LTSC 2019 (Windows10 1809)
  2. Ubuntu 20.04 Server

在Windows上啓用OpenSSH

使用管理員權限打開PS,運行以下命令

# 檢查是否有OpenSSH功能
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

配置OpenSSH服務

# Start the sshd service
Start-Service sshd

# OPTIONAL but recommended: 
Set-Service -Name sshd -StartupType 'Automatic'

# Confirm the firewall rule is configured. It should be created automatically by setup.
Get-NetFirewallRule -Name *ssh*

# There should be a firewall rule named "OpenSSH-Server-In-TCP", which should be enabled
# If the firewall does not exist, create one 防火牆配置,允許22/TCP
New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22

啓用成功:

SCP命令

Linux推送到Windows

# scp 文件路徑 用戶名@主機名/IP:保存路徑
# 例如將test.txt文件發送到Windows主機的D盤根目錄
scp test.txt [email protected]:d://
# 從Windows上傳文件到Ubuntu的/root目錄
scp .\test.txt [email protected]:/root
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章