LoginSignup
29
26

More than 5 years have passed since last update.

Emacsでssh用アカウントでリモート入ってsudoしてファイル編集したい場合

Posted at

ssh用アカウントでリモートサーバーログインしてapacheの設定ファイルとか編集したい!
だからsudoしたい!でもrootでssh出来ない!さてどうするか。

自分の設定が記述ミス等があるのか、他の方のブログ見て真似してもうまく行かなかった。
調べてたら以下のようにすれば、ssh用(非root)でsshリモートログインしてsudoしてファイル開いて編集できる
方法が見つかった。

[ C-xC-f] /ssh:user@server|sudo:server:/path/to/file RET

userはssh用のアカウント、
serverはsshログイン先リモートホスト(~/.ssh/configに接続設定書いておくと楽)
/path/to/fileは見ての通り目的のファイルもしくはディレクトリ
要は「sshでログイン」して「sudoでファイル開く」を「|(パイプ)」でつなぐだけでした。

接続時にパスワード聞かれたりするけど、それはまぁいいかなって。

参考:http://wikemacs.org/index.php/TRAMP

29
26
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
29
26