GNU/Linux >> Linux の 問題 >  >> Ubuntu

Ubuntu 14.04でスポーンコマンドが見つかりませんか?

Ubuntu 14.04を使用しており、GeoIPを使用して国ごとにSSHログインをブロックしたい(https://www.axllent.org/docs/view/ssh-geoip/から)

コマンドの出力を見つけてください:

$ spawn
spawn: command not found

expectをインストールしました パッケージはまだ機能していません:

apt-get install expect
expect is already the newest version

次のスクリプトを実行したい:

cat /etc/hosts.allow
sshd: ALL: spawn /usr/local/bin/sshfilter.sh %a

同じことについて何か考えがありますか?

承認された回答:

この場合、spawnのようです spawnを指します hosts.allowの拡張 RUNNING OTHER COMMANDSで説明されている構文 hosts_options(5)のマニュアルページのセクション(man hosts_options ):

RUNNING OTHER COMMANDS
    aclexec shell_command
           Execute,  in a child process, the specified shell command, after
           performing   the   %<letter>   expansions   described   in   the
           hosts_access(5)  manual  page.   The  command  is  executed with
           stdin, stdout and stderr connected to the null device,  so  that
           it won't mess up the conversation with the client host. Example:

              smtp : ALL : aclexec checkdnsbl %a

           executes,  in  a  background  child  process,  the shell command
           "checkdnsbl %a" after replacing %a by the address of the  remote
           host.

           The  connection  will be allowed or refused depending on whether
           the command returns a true or false exit status.

    spawn shell_command
           Execute, in a child process, the specified shell command,  after
           performing   the   %<letter>   expansions   described   in   the
           hosts_access(5) manual  page.   The  command  is  executed  with
           stdin,  stdout  and stderr connected to the null device, so that
           it won't mess up the conversation with the client host. Example:

              spawn (/usr/sbin/safe_finger -l @%h | /usr/bin/mail root) &

           executes, in a  background  child  process,  the  shell  command
           "safe_finger  -l @%h | mail root" after replacing %h by the name
           or address of the remote host.

spawnという事実 そのコンテキスト外で(つまり、シェルのコマンドとして)実行しようとすると、エラーが返されます。別の問題であるGeoIPフィルタリングスクリプトの適切な操作に問題がある場合は、心配する必要はありません。

hosts.allow spawnの正常な動作を示すため Ubuntu 14.04の拡張機能は、GeoIPに絡まることなく、IPアドレスをログに記録して0を返す最小限の実行可能ファイル/usr/local/bin/sshfilter.shスクリプトを作成できます。例:

#!/bin/sh

logger "$0: connection from $1"

exit 0

次に、次の行をhostsファイルに追加します。

関連:Ubuntuがログイン画面で動かなくなった?

hosts.deny:

sshd: ALL

hosts.allow:

sshd: ALL: spawn /usr/local/bin/sshfilter.sh %a

次に実行します

tail -f /var/log/syslog

あるターミナルウィンドウで、別のウィンドウでSSH経由でログインを試みます:

ssh localhost

のようなメッセージがsyslogテールに表示されるはずです。
Jul 25 08:03:59 T61p logger: /usr/local/bin/sshfilter.sh: connection from 127.0.0.1

aclexecでも動作することを確認できます spawnの代わりに 、リンクした記事で提案されているように。 実際、この場合はaclexecを使用する必要があります spawn以降 生成されたプロセスの終了コードを使用して、接続を許可するかどうかを決定しません–どのaclexec


Ubuntu
  1. (解決済み)apt-add-repositoryコマンドが見つかりません–UbuntuとDebian

  2. Tr:コマンドが見つかりませんか?

  3. ifrename:コマンドが見つかりません

  1. id:コマンドが見つかりません

  2. w:コマンドが見つかりません

  3. ln:コマンドが見つかりません

  1. df:コマンドが見つかりません

  2. du:コマンドが見つかりません

  3. rm:コマンドが見つかりません