thisismak
thisismak
2020-12-07 23:24

請問有高手能解決Shell -c""問題?

50
  • ubuntu
  • linux
  • bash
  • centos

請問有高手能解決Shell -c""問題? 用Excel因為希望方便其他使用者在指定Excel經&$L$6&修改指定內容完成工作

Shell一鍵功能指令
sudo bash -c "echo root:Y6y9GaAZF6 | chpasswd && sed -i 's/prohibit-password/yes/' /etc/ssh/sshd_config || sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' && sed -i 's/Port .*/Port 33888/g' /etc/ssh/sshd_config || sed -i 's/#Port .*/Port 33888/g' /etc/ssh/sshd_config && service sshd restart && history -c"

Shell一鍵功能指令 + Excel函數
="sudo bash -c "echo root:"&$L$6&" | chpasswd && sed -i 's/prohibit-password/yes/' /etc/ssh/sshd_config || sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' && sed -i 's/Port .*/Port "&$L$7&"/g' /etc/ssh/sshd_config || sed -i 's/#Port .*/Port "&$L$7&"/g' /etc/ssh/sshd_config && service sshd restart && history -c""

-----------------------以下為真實指令
sudo bash -c ""
echo root:Y6y9GaAZF6 | chpasswd
sed -i 's/prohibit-password/yes/' /etc/ssh/sshd_config || sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' 
sed -i 's/Port .*/Port 33888/g' /etc/ssh/sshd_config || sed -i 's/#Port .*/Port 33888/g' /etc/ssh/sshd_config
service sshd restart
history -c"

  • 点赞
  • 收藏
  • 复制链接分享

2条回答

为你推荐

换一换