パスワードなしでSSHを使用してリモートホストでコマンドの使用を有効にする方法は?

パスワードなしでSSHを使用してリモートホストでコマンドの使用を有効にする方法は?

2 つのホスト間で SSH が有効になっており、パスワードは不要です。

SSHログインは正常に機能しますが、次のエラーでコマンドの実行が失敗します。

**isn't allowed to be executed with process or redirect controls.**

利用可能な簡単なコマンド:

ssh remo-tehost " echo \"\test\"  >> \"/home/alarmstest.log\" "

私が得る実行追跡:

debug1: Sending command:  echo "test"  >> "/home/alarmstest.log" 
debug2: channel 0: request exec confirm 1
debug2: fd 3 setting TCP_NODELAY
debug2: callback done
debug2: channel 0: open confirm rwindow 0 rmax 32768
debug2: channel 0: rcvd adjust 2097152
debug2: channel_input_status_confirm: type 99 id 0
debug2: exec request accepted on channel 0
debug2: channel 0: rcvd ext data 117

リモートサーバーのsudoshユーザーが使用するuser:x:500:500::/home/user:/usr/local/bin/sudoshauthorized_keysがあります。 -rw内部+キー-------ユーザー1人ユーザー9092 12月13日07:53 authenticate_keys

ベストアンサー1

これは引用問題のようです。 sshを介してシェルコマンドを実行しようとするたびに、リモートシェル(Bashなど)はそれを引用符のペア/bin/bash -c <command-line>として受け取ることに注意してください。

ssh remo-tehost "echo test  >> /home/alarmstest.log"

このペアは、ローカルシェル(つまり、コマンドラインの実行に使用されるシェル)が引数を解釈するのを防ぐために重要です。

おすすめ記事