1. ssh到遠(yuǎn)程Linux服務(wù)器上告组。
#######win10 1809以上版本薯鳍,可以CMD里面輸入sshd直接連接。
其他版本請(qǐng)使用 Putty, Xshell,SecureCrt等軟件遠(yuǎn)程連接到Linux服務(wù)器.
########2.在Linux服務(wù)器上安裝Powershell
有internet連接的情況運(yùn)行如下命令
\# Register the Microsoft RedHat repository
curl https://packages.microsoft.com/config/rhel/7/prod.repo | sudo tee /etc/yum.repos.d/microsoft.repo
# Install PowerShell
sudo yum install -y powershell
# Start PowerShell
pwsh
內(nèi)網(wǎng)沒(méi)有internet連接的情況,請(qǐng)使用如下方式
下載 powershell包到本地目錄
更多Linux版本下載包請(qǐng)參考如下連接
https://github.com/PowerShell/PowerShell/releases/tag/v7.1.4
安裝Powershell
yum install powershell-7.1.4-1.rhel.7.x86_64.rpm
Start Powershell
pwsh
3.配置OpenSSH
##編輯配置文件 /etc/ssh/sshd_config.確保文件有如下條目盔然。如果沒(méi)有請(qǐng)?zhí)砑?PasswordAuthentication yes
Subsystem powershell /usr/bin/pwsh -sshs -NoLogo
#注意該路徑下有一個(gè)ssh_config文件,如果編輯錯(cuò)誤是嗜,會(huì)出現(xiàn)錯(cuò)誤Enter-PSSession: The background process reported an error with the following message: The SSH client session has ended with error message: subsystem request failed on channel 0.
4.重啟sshd服務(wù)
systemctl restart sshd
5.回到windows機(jī)器愈案。運(yùn)行如下命令遠(yuǎn)程連接linux服務(wù)器《焯拢或者執(zhí)行腳本等操作站绪。
Enter-PSSession -HostName root@172.31.220.4 -SSHTransport