Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
リモートサーバーに(user1に)接続し、いくつかのコマンドを実行できる必要があるPythonスクリプトを作成する必要があります(これは簡単でした)。次に、sudo su - user2を介してuser2に切り替え、いくつかのコマンドを実行する必要があります(問題ここにある)。パスワードを要求せずに user2 に切り替えて (スクリプトのどこかにパスワードを入れることができます)、user2 としてコマンドを実行するにはどうすればよいでしょうか。
ありがとう、
-S(大文字の「S」)を試してください。sudo の man ページを引用します。
-S
-S The -S (stdin) option causes sudo to read the password from the standard input instead of the terminal device.