Execute a linux shell command with “sudo” using java, without entering the required password

后端 未结 3 1539
野性不改
野性不改 2020-12-06 08:20

Hi I\'m using ganymed-ssh2 java library to execute remote commands in linux workstation with success.

But now there is a situation where I need to execute a command

3条回答
  •  北荒
    北荒 (楼主)
    2020-12-06 08:50

    assuming there is a sess.getStdin(), you should be able to pipe in a password to the sudo command.

提交回复
热议问题