34
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.

指定コマンドしか実行できない鍵の設定

Posted at

webサーバのバックでsshさせて結果を出力すると便利。

grepしかできない公開鍵設定の例

myserver:~/.ssh/authorized_keys
from="11.22.33.44",command="/bin/grep ${SSH_ORIGINAL_COMMAND} /var/log/maillog.1 /var/log/maillog",no-pty,no-port-forwarding,no-X11-forwarding,no-agent-forwarding ssh-rsa 〜SSHの公開鍵〜
  • from=で接続元IPアドレスの制限
  • command=の${SSH_ORIGINAL_COMMAND}にはsshの引数が入る。

引数を指定する

$ ssh myserver -i ~/.ssh/myserver_grep_only/id_rsa \
  test@live.com

とすると、${SSH_ORIGINAL_COMMAND}にtest@live.comが入る。

確認方法

~/.ssh/authorized_keysにcommand="env"としておけば見れます。

34
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
34
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?