要在EC2实例上运行sudo的命令 [英] To run sudo commands on a ec2 instance
问题描述
我不能在我的EC2客户端上运行命令苏,我ssh到客户端通过一个Java程序,并通过程序运行命令。 我可以如ls和使用ifconfig,尽管运行命令。
I cannot run "sudo su" on my ec2 client , I ssh into the client through a java program and run the command through a program. I can run commands like "ls" and "ifconfig" though.
我得到一个错误说。须藤:对不起,你必须有一个tty运行sudo的
I get an error saying "sudo: sorry, you must have a tty to run sudo".
我怎样才能运行该命令,我使用Jsch的ssh来我的EC2实例。
How can I run the command, I am using Jsch for ssh to my ec2 instance.
推荐答案
您可以做的命令无伪终端与JSch,使用 -S
选项须藤
。
You can do "sudo" without pseudo-tty with JSch, by using the -S
option to sudo
.
请参见 Sudo.java 中的JSch网站上的一个完整的例子。
See the Sudo.java on the JSch website for a complete example.
(我JSch的作者。)
(I'm the author of JSch.)
这篇关于要在EC2实例上运行sudo的命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!