38
36

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

SSHコマンドの引数からsudoを実行する

Last updated at Posted at 2013-07-05

エラーになる

リモート端末へSSHコマンドの引数からsudoを実行すると下記のようにエラーになります。

> ssh 'user'@'server' sudo /etc/init.d/http restart
sudo: sorry, you must have a tty to run sudo

RHEL/CentOS5系のOSでは、セキュリティとしてttyがないとsudoコマンドを実行出来ないように設定されているらしい。

仮想端末を割り当てて通す

> ssh -t 'user'@'server' sudo /etc/init.d/http restart

「-tオプション」を付けることによって、強制的に仮想端末が割り当てられsudoコマンドを実行することが出来る

38
36
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
38
36

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?