2019年8月10日 星期六

[Linux 常見問題] Proper way to sudo over ssh

Source From Here 
Question 
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) 
  1. # ssh user@server "sudo script"  
What's the proper way to do this so I can type the password for sudo over SSH without the password appearing as I type? Below is the related error message: 
sudo: no tty present and no askpass program specified


How-To 
Another way is to use the -t switch to ssh: 
# ssh -t user@server "sudo script"

See man ssh: 
  1. -t      Force pseudo-tty allocation.  This can be used to execute arbi-  
  2.         trary screen-based programs on a remote machine, which can be  
  3.         very useful, e.g., when implementing menu services.  Multiple -t  
  4.         options force tty allocation, even if ssh has no local tty.  


沒有留言:

張貼留言

[Git 常見問題] error: The following untracked working tree files would be overwritten by merge

  Source From  Here 方案1: // x -----删除忽略文件已经对 git 来说不识别的文件 // d -----删除未被添加到 git 的路径中的文件 // f -----强制运行 #   git clean -d -fx 方案2: 今天在服务器上  gi...