Closed. This question is not reproducible or was caused by typos。它当前不接受答案。












想改善这个问题吗?更新问题,以便将其作为on-topic用于堆栈溢出。

5个月前关闭。



Improve this question




尝试使用sshpass时,出现语法错误,如下所示。
case $var in
        1)
            echo "connecting: SERVER1" ;;
            sshpass -p "SomePassw0rd" ssh [email protected] ;;
        2)
            echo "connecting: SERVER2" ;;
            sshpass -p "SomePassw0rd123" ssh [email protected] ;;
esac
Eroor:
./test1: line 4: syntax error near unexpected token `-p
./test1: line 11: sshpass -p "SomePassw0rd" ssh [email protected]
您能否指导如何解决此问题。谢谢。

最佳答案

case $var in
        1)
            echo "connecting: SERVER1"
            sshpass -p "SomePassw0rd" ssh [email protected]
            ;;
        2)
            echo "connecting: SERVER2"
            sshpass -p "SomePassw0rd123" ssh [email protected]
            ;;
esac
您可能还需要考虑使用sshpass -f passwordfile.txt,以避免与在命令行上输入密码有关的安全问题。

10-06 01:58