使用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