加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
ubuntu1804_install_powershell.bash 1.59 KB
一键复制 编辑 原始数据 按行查看 历史
chuanjiao10 提交于 2019-11-27 02:07 . 更新readme
#
if grep -Eq 'Bionic Beaver' /etc/issue || grep -Eq 'Bionic Beaver' /etc/*-release
then
echo 'linux is ubuntu1804'
if [ -h /usr/bin/pwsh ]
then
echo 'powershell installed on ubuntu1804'
if grep -Eq 'powershell' /etc/ssh/sshd_config
then
echo 'powershell_sshd_good'
exit 0
else
echo '' >> /etc/ssh/sshd_config
echo 'Subsystem powershell /usr/bin/pwsh -sshs -NoLogo -NoProfile' >> /etc/ssh/sshd_config
echo 'UseDNS no' >> /etc/ssh/sshd_config
echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config
systemctl restart sshd.service
echo 'powershell_sshd_fixed'
exit 0
fi
else
echo 'installing powershell now'
sudo snap remove powershell
sudo curl -o /tmp/a.deb https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb
sudo dpkg -i /tmp/a.deb
sudo apt-get update
sudo add-apt-repository universe
sudo apt-get remove -y powershell
sudo apt-get install -y powershell
if [ $? -ne 0 ]
then
echo 'install fall'
exit 3
else
echo 'install powershell sucess'
fi
if grep -Eq 'powershell' /etc/ssh/sshd_config
then
echo 'powershell_sshd_good'
exit 0
else
echo '' >> /etc/ssh/sshd_config
echo 'Subsystem powershell /usr/bin/pwsh -sshs -NoLogo -NoProfile' >> /etc/ssh/sshd_config
echo 'UseDNS no' >> /etc/ssh/sshd_config
echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config
systemctl restart sshd.service
echo 'powershell_sshd_fixed'
exit 0
fi
fi
else
echo 'linux not ubuntu1804'
exit 2
fi
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化