set environment variable SSH_ASKPASS or askpass in sudoers, resp

后端 未结 6 2066
孤城傲影
孤城傲影 2021-02-07 07:12

I\'m trying to login to a ssh server and to execute something like:

ssh user@domain.com \'sudo echo \"foobar\"\'
         


        
6条回答
  •  一向
    一向 (楼主)
    2021-02-07 08:00

    Rather than allocating a TTY, or setting a password that can be seen in the command line, do something like this.

    Create a shell file that echo's out your password like:

    #!/bin/bash
    
    echo "mypassword"
    

    then copy that to the node you want using scp like this:

    scp SudoPass.sh somesystem:~/bin
    

    Then when you ssh do the following:

    ssh somesystem "export SUDO_ASKPASS=~/bin/SudoPass.sh;sudo -A command -parameter"
    

提交回复
热议问题