proper way to sudo over ssh

后端 未结 9 1808
抹茶落季
抹茶落季 2020-11-28 20:33

I have a script which runs another script via SSH on a remote server using sudo. However, when I type the password, it shows up on the terminal. (Otherwise it works fine)

9条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-28 20:59

    I faced a problem,

    user1@server1$ ssh -q user1@server2 sudo -u user2 rm -f /some/file/location.txt
    
    Output:
    sudo: no tty present and no askpass program specified
    

    Then I tried with

    #1
    vim /etc/sudoers
    Defaults:user1    !requiretty
    

    didn't work

    #2
    user1   ALL=(user2)         NOPASSWD: ALL
    

    that worked properly!

提交回复
热议问题