authorized_keys
のcommand=
オプションにパイプを含むコマンドを指定できるか実験。
command="find /home/satob -maxdepth 1 -name '*.sh' | xargs grep '#!'" ssh-ed25519 AAAAC3Nz... pipe@example.com
実行してみたらこんな感じ。問題なく実行できた。結局、内部では/etc/passwd
で指定されたシェルが動いているから、ログインシェルでできることはcommand=
でも可能みたい。
$ ssh -i id_pipe satob@localhost
/home/satob/sanitize1.sh:#!/bin/bash
/home/satob/sanitize2.sh:#!/bin/bash
/home/satob/sanitize4.sh:#!/bin/bash
/home/satob/sanitize3.sh:#!/bin/bash
Connection to localhost closed.
$0
も参照できた。
command="echo $0" ssh-ed25519 AAAAC3Nz... shtype@example.com
$ ssh -i id_shtype satob@localhost
bash
Connection to localhost closed.
シェルは/etc/passwd
で指定したものが使われる、という話は以下を参照。/sbin/nologin
を指定しているユーザでもsshでトンネリングはできるが、command=
は使えないことになる。
unix.stackexchange.com