使用PowerShell連接Ubuntu


Ubuntu安裝PowerShell

Ubuntu安裝PowerShell幫助文檔

# Download the Microsoft repository GPG keys
wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb

# Register the Microsoft repository GPG keys
sudo dpkg -i packages-microsoft-prod.deb

# Update the list of products
sudo apt-get update

# Enable the "universe" repositories
sudo add-apt-repository universe

# Install PowerShell
sudo apt-get install -y powershell

# Start PowerShell
pwsh

配置Ubuntu允許PowerShell通過SSH連接

配置Ubuntu允許PowerShell通過SSH連接

# 安裝SSH
sudo apt install openssh-client
sudo apt install openssh-server

# 編輯 /etc/ssh 位置中的 sshd_config 文件。
# 確保已啟用密碼身份驗證:
PasswordAuthentication yes
# 添加 PowerShell 子系統條目:
Subsystem powershell /usr/bin/pwsh -sshs -NoLogo -NoProfile

# 啟用密鑰身份驗證(可選)
PubkeyAuthentication yes

重啟 sshd 服務

sudo service sshd restart

在Windows下通過PowerShell 連接 Ubuntu

通過PowerShell 連接 Ubuntu

New-PSSession -HostName UserA@LinuxServer01

參考文檔


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM