====== SSH および FTP でのデータ転送設定 ====== {{indexmenu_n>1}} [[ja:documentation:start|Pandora FMS ドキュメント一覧に戻る]] ===== 概要 ===== The standard transfer method in Pandora FMS to send files, [[:en:documentation:08_technical_reference:09_tentacle|Tentacle]], needs the [[https://en.wikipedia.org/wiki/Perl|Perl]] programming language installed. Some devices, such as ESX systems (UNIX), lack this tool. When this happens, the alternatives are to use FTP or SSH to transfer monitoring data. Pandora FMS で標準の転送方法(tentacle)を使用できない場合があります。これは、[[https://en.wikipedia.org/wiki/Perl|Perl]] が無い Unix システム(ESX システムなど)を使用している場合で、古いシェルスクリプトのエージェントを使用する場合です。 この場合は、FTP または SSH を使用してファイルを転送することができます。 {{ :wiki:pfms-server-ftp-ssh-data.png?nolink& }} Pandora FMS can use the FTP or SSH protocol to copy the XML data packages generated by the [[:en:documentation:01_understanding:03_glossary#software_agent|software agents]] to the PFMS server. Pandora FMS は、SSH プロトコルを使用して、[[:ja:documentation:01_understanding:03_glossary#ソフトウエアエージェント|ソフトウエアエージェント]]によって生成された XML データパッケージをサーバにコピーできます。 ===== Pandora FMS へのデータ取り込みのための SSH 設定 ===== Always keep in mind Pandora FMS [[:en:documentation:07_technical_annexes:15_security_architecture|Security Architecture]]. 常に、Pandora FMS の [[:ja:documentation:07_technical_annexes:15_security_architecture|セキュリティアーキテクチャ]] に注意してください。 Consider Pandora FMS server as **Server** and each one of the devices running the Software Agent as **Client**. You may always check which user you are working with by means of the **whoami** command. Pandora FMS サーバを **サーバ** と見なし、ソフトウェアエージェントを実行している各デバイスを **クライアント** と見なします。 **whoami** コマンドを使用して、作業しているユーザをいつでも確認できます。 ==== サーバでのユーザ作成 ==== **Step 1**: Create a ''pandora'' user in the machine where Pandora FMS server is running. This machine will receive the data through SSH. If you have already installed a Pandora FMS server, surely this user is already created. Set a strong password for that user with the command: **ステップ 1**: Pandora FMS サーバがインストールされているホストに ''pandora'' ユーザを作成します。このユーザーは SSH を介してデータを受信します。 Pandora FMS サーバがすでにインストールされている場合は、このユーザはすでに作成済です。 次のコマンドを使用して、このユーザに強力なパスワードを設定します。 passwd pandora ==== サーバのユーザ設定 ==== **Step 2**. Once within the server, create the ''/home/pandora/.ssh'' directory with ''750'' permissions and ''pandora:root user''. **ステップ 2**: サーバ内で、パーミッション ''750'' およびユーザ ''pandora:root'' で ''/home/pandora/.ssh'' ディレクトリを作成します。 ==== クライアントでの鍵作成 ==== **Step 3**: Create, on each machine running a Software Agent that will use SSH, a pair of keys (private and public). To do this, execute the following command **with the same user with which Pandora FMS Software Agent is executed**: **ステップ 3**: SSH を使用する必要があるエージェントの各システムで、鍵のペア(秘密鍵と公開鍵)を作成します。 これを行うには、Pandora FMS エージェントの実行に使用されるユーザで次のコマンドを実行します。 ssh-keygen A series of questions will appear to which you will have to answer by simply pressing the Enter key. With this you have created a public key and a private key for that user in the machine. Now you should copy it to the destination machine, which is the Pandora FMS server where you want to send the monitoring data. いくつかの質問が表示されます。Enter キーを押すだけで回答できます。 このユーザの公開/秘密鍵がシステムに作成されます。 次に、データの送信先である Pandora FMS サーバであるターゲットシステムにコピーします。 ==== 公開鍵のサーバへのコピー ==== **Step 4**: Copy the public key to the Pandora FMS **Server**. The public key you just generated can be copied in two ways. **ステップ 4**: 公開鍵を Pandora FMS サーバにコピーします。 作成された公開鍵をコピーするには、2つの方法があります。 === 手動コピー === The public key file generated in the **Client** is: **クライアント** で生成された公開鍵は以下にあります。 /home//.ssh/id_rsa.pub Where '''' is the user name that runs Pandora FMS Software Agent in the **Client**. If the key pair was generated as root user, it will be in: ここで、'''' は、**クライアント**で Pandora FMS ソフトウエアエージェントを実行するユーザ名です。鍵のペアを root ユーザで生成した場合は、以下にあります。 /root/.ssh/id_rsa.pub This file will have a content similar to this one: このファイルには次のようなものが含まれます。 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAzqyZwhAge5LvRgC8uSm3tWaFV9O6fHQek7PjxmbBUxTWfvNbbswbFsF0esD3COavziQAUl3rP8DC28vtdWHFRHq+RS8fmJbU/VpFpN597hGeLPCbDzr2WlMvctZwia7pP4tX9tJI7oyCvDxZ7ubUUi/bvY7tfgi7b1hJHYyWPa8ik3kGhPbcffbEX/PaWbZ6TM8aOxwcHSi/4mtjCdowRwdOJ4dQPkZp+aok3Wubm5dlZCNLOZJzd9+9haGtqNoAY/hkgSe2BKs+IcrOAf6A16yiOZE/GXuk2zsaQv1iL28rOxvJuY7S4/JUvAxySI7V6ySJSljg5iDesuWoRSRdGw== root@dragoon This content must be added to the end of the ''authorized_keys'' file on the **Server**. Its path is: この内容を、**サーバ** の ''authorized_keys'' ファイルの最後に追加する必要があります。パスは次の通りです。 /home/pandora/.ssh/authorized_keys The ''authorized_keys'' file on the Server must belong (ownership) to the user ''pandora:root'' and must have permissions ''600'' サーバの ''authorized_keys'' ファイルの所有者とグループは ''pandora:root'' で、パーミッションは ''600'' である必要があります。 === 自動コピー === Use the following command at **Client**: **クライアント** にて次のコマンドを利用します。 ssh-copy-id pandora@ Where '''' is the IP address or URL of the **Server**. ここで、'''' は、**サーバ** の IP アドレスまたは URL です。 It will ask for the server's ''pandora'' user password ([[:en:documentation:07_technical_annexes:01_ssh_and_ftp_setup#user_creation_in_server|set in step 1]]) and, once confirmed, it will display a message similar to the following: ''pandora'' ユーザのパスワード([[:ja:documentation:07_technical_annexes:01_ssh_and_ftp_setup#サーバでのユーザ作成|ステップ 1 で設定]])を要求します。これが確認されると、次のようなメッセージが表示されます。 Now try logging into the machine, with "ssh ''", and check in: .ssh/authorized_keys to make sure we haven't added extra keys that you weren't expecting. Perform this test to verify automatic connection to Pandora FMS **Server** with the ''pandora'' user from the **Client** (with the user running the Software Agent): **クライアント** (のソフトウエアエージェント実行ユーザ)から、Pandora FMS **サーバ**の ''pandora'' ユーザへ自動接続が可能であることを確認します。 ssh pandora@ Once you are able to connect to the **Server** as described above, the Software Agent on the **Client** will be able to start sending monitoring data. 上記のように **サーバ** に接続できるようになると、**クライアント**のソフトウェアエージェントは監視データの送信を開始できるようになります。 ==== クライアント設定 ==== Once you have verified the connection through SSH, this will be the method used by the software agents to copy data to Pandora FMS Server directory. This directory is located at: SSH を介した接続を確認できたら、これがソフトウェアエージェントがデータを Pandora FMS サーバディレクトリにコピーするために使用される方法になります。 このディレクトリは次の場所にあります。 /var/spool/pandora/data_in Also make sure that the directory ''/var/spool/pandora/data_in'' exists and the ''pandora'' user has writing permissions, otherwise it will not work. また、''/var/spool/pandora/data_in'' ディレクトリが存在し、ユーザ ''pandora'' に書き込み権限があることを確認してください。そうでない場合は機能しません。 Finally, modify the [[:en:documentation:02_installation:05_configuration_agents#transfer_mode|software agent configuration]] in the **Client** to specify that the copying method is SSH. This is modified in ''/etc/pandora/pandora_agent.conf'' file, in the ''transfer_mode'' configuration token. Remember to restart the software agent service on each Client after this change. 最後に、クライアントの [[:ja:documentation:02_installation:05_configuration_agents#transfer_mode|ソフトウエアエージェント設定]]を変更して、コピー方法を tentacle ではなく ssh に設定します。 これは ''/etc/pandora/pandora_agent.conf''ファイルの ''transfer_mode'' 設定トークンで行います。この変更後は、クライアントのソフトウエアエージェントサービスを再起動することを忘れないでください。 ==== SSH サーバのセキュリティ強化 ==== [[https://pandorafms.com/blog/information-security/|{{ :wiki:pfms-cyber_attack.png?nolink& |Absolutely no one is safe from security attacks}}]] Pandora FMS uses, among others, sftp/ssh2 ([[https://es.wikipedia.org/wiki/Secure_Copy|SCP]]) to copy data files from the software agents to the server. Therefore, you will need at least one data server with an SSH2 server listening to the ''pandora'' user. This could be a significant risk in a network that needs to be strictly secured. OpenSSH2 is **very** secure, but in terms of computer security, there is nothing that is absolutely secure; so, measures must be taken to make it "more" secure. Pandora FMS は、特に sftp/ssh2(scp) を使用して、エージェントからサーバにデータファイルをコピーします。 このため、''pandora'' ユーザを待ち受ける SSH2 サーバを備えた少なくとも 1つのデータサーバが必要です。 これは、厳密にセキュリティ保護する必要があるネットワークにとって重大なリスクになる可能性があります。 Open SSH2 は **非常に** 安全ですが、コンピュータのセキュリティに関しては、絶対に安全なものはないため、"より安全" にするための対策を講じてください。 Always keep in mind Pandora FMS [[:en:documentation:07_technical_annexes:15_security_architecture|Security Architecture]]. 常に、Pandora FMS の [[:en:documentation:07_technical_annexes:15_security_architecture|セキュリティアーキテクチャ]] に注意してください。 It is possible to prevent SSH access for certain users, as well as to configure restrictions on FTP access. FTP を介したアクセスに制限を設定するのと同じように、SSH を介した特定のユーザのアクセスを禁止することも可能です。 To do this, modify the ''pandora'' user on the **Server**. This user must have a [[:en:documentation:07_technical_annexes:01_ssh_and_ftp_setup#user_creation_in_server|strong password]]. Its login shell will be changed to restrict SSH access to the user, and its ''home'' directory, to prevent its access to other folders: それを行うするには、**サーバ** の ''pandora'' ユーザの設定を変更します。 このユーザには[[:ja:documentation:07_technical_annexes:01_ssh_and_ftp_setup#サーバでのユーザ作成|強力なパスワード]]が必要です。 他のフォルダーへのアクセスを回避するために、ログインシェルを変更しホームディレクトリを変更します。 usermod -s /sbin/nologin -d /var/spool/pandora/data_in pandora With these changes to the ''pandora ''user on the **Server**, when logging in via SSH, such user will not be able to execute commands with it in an interactive terminal. **サーバ** の ''pandora'' ユーザに対するこの変更で、該当ユーザが SSH でログインした際にはターミナルでコマンドを実行できなくなります。 (See the [[:es:documentation:02_installation:01_installing#requisitos_minimos_de_software|recommended operating systems]] for Pandora FMS.) In Debian systems the shell path is ''/usr/sbin/nologin''. (Pandora FMS の [[:ja:documentation:02_installation:01_installing#最低ソフトウエア要件|推奨 OS]] を確認してください。) Debian システムでは、シェルは ''/usr/sbin/nologin'' です。 ===== FTP にてサーバがデータを受け取る設定 ===== The client settings for sending data via FTP allow you to specify the user and password to be sent, making it quite easy to implement FTP copying instead of [[:en:documentation:08_technical_reference:09_tentacle|Tentacle]]. FTP 経由でデータを送信するクライアント設定は、送信するユーザとパスワードの指定で可能です。[[:ja:documentation:08_technical_reference:09_tentacle|tentacle]] の代わりに FTP を介してコピーを実装するのは非常に簡単です。 [[https://pandorafms.com/blog/file-transfer-protocol/|{{ :wiki:pfms-what-is-ftp.png?nolink& |What is File Transfer Protocol (FTP)?}}]] Besides configuring Pandora FMS software agents to send data with FTP, **you will have to configure an FTP server where you execute Pandora FMS server**, [[:en:documentation:07_technical_annexes:01_ssh_and_ftp_setup#creating_a_server_user|establish a password]] for the ''pandora'' user and allow writing access to the ''pandora'' user to the ''/var/spool/pandora/data_in'' directory and its subdirectories. FTP を使用してデータを送信するように Pandora FMS エージェントを設定するほか、Pandora FMS サーバに FTP サーバを設定し、ユーザ ''pandora'' (Pandora FMS エージェントで使用する)のパスワードを設定し、''pandora'' ユーザに ''/var/spool/pandora/data_in'' 以下の書き込みアクセスを許可します。 This means that you should configure the FTP server to adapt it to these needs; for this, in this guide **[[https://de.wikipedia.org/wiki/Vsftpd|vsFTPd]]** is used. ニーズに合わせて FTP サーバを設定します。このガイドでは **[[https://en.wikipedia.org/wiki/Vsftpd|vsFTPd]]** を使用します。 ==== Vsftpd でのセキュリティ強化 ==== Tentacle の代わりに FTP を使用することの短所は、FTP を介したデータ送信は安全ではないため、Pandora FMS サーバで FTP サーバを実行することが脆弱になります。 以下のセクションでは、サーバーの安全性を最小限にする方法について説明します。 For this reason, and in the same way that the [[:en:documentation:07_technical_annexes:01_ssh_and_ftp_setup#ssh_server_assuring|SSH login has been disabled]] for the ''pandora'' user for security reasons, a safe access method should be established for the FTP users. A safe and simple method for this is to create a PAM rule for **vsftpd**. For this you should create a file called ''/etc/pam.d/ftp'' containing the following: 安全上の理由で ''pandora'' ユーザの [[:ja:documentation:07_technical_annexes:01_ssh_and_ftp_setup#ssh_サーバのセキュリティ強化|SSH 経由のログインを無効にする]]のと同様に、FTP 経由の安全なアクセス方法を設定する必要があります。簡単で安全な方法は、**vsftpd** の PAM ルールを作成することです。 次の内容の ''/etc/pam.d/ftp'' ファイルを作成します。 auth required pam_listfile.so item=user sense=deny file=/etc/ftpusers onerr=succeed # Standard pam includes @include common-account @include common-session @include common-auth auth required pam_succeed_if.so quiet user ingroup pandora auth required pam_succeed_if.so quiet shell = /sbin/nologin (See the [[:es:documentation:02_installation:01_installing#requisitos_minimos_de_software|recommended operating systems]] for Pandora FMS.) In Debian systems the shell path is ''/usr/sbin/nologin''. (Pandora FMS の [[:ja:documentation:02_installation:01_installing#最低ソフトウエア要件|推奨 OS]] を確認してください。) Debian システムでは、シェルは ''/usr/sbin/nologin'' です。 In the configuration file of **vsftpd** (''/etc/vsftpd.conf'') search the token ''pam_service_name'' and set the name of the created file: **vsftpd** の設定ファイル(''/etc/vsftpd.conf'') で、''pam_service_name'' トークンを探し、作成したファイル名を入力します。 pam_service_name=ftp With this configuration, only the users that belong to the ''pandora'' group and have ''nologin'' as associated //shell// will be able to connect to Pandora FMS by FTP, //so you should create the// ''pandora'' //group// that includes the ''pandora'' user. In any case, verify that both exist in the **Server**. この設定により、''pandora'' グループに属し、''nologin'' のシェルを持つユーザのみが FTP 経由でPandora FMS にアクセスできます。 そのため、''pandora'' ユーザを含むグループ ''pandora'' を作成する必要があります(存在しない場合)。 With a last configuration of the ''/etc/vsftpd.conf'' file, the access of the users that access by FTP its root directory will be restricted. The parameters are as follows: ''/etc/vsftpd.conf'' ファイルにて、いくつかの設定を調整するだけで、FTP 経由でログインするユーザの root へのアクセスを制限できます。 パラメータは次のとおりです。 chroot_local_user=YES chroot_list_enable=YES chroot_list_file=/etc/vsftpd.nochroot_list In case you need to exclude a user from this and avoid restricting it to your **Chroot**, just include that user in this ''vsftpd.nochroot_list'' file (one user per line). 一部のユーザを除外し、**Chroot** に制限することを避ける必要がある場合は、''vsftpd.nochroot_list'' ファイルにそのユーザを含めます(1行に1ユーザー)。 Other options to be configured to implement higher security are the following: セキュリティを強化するための他のオプションは次のとおりです。 dirlist_enable=NO download_enable=NO deny_file=authorized_keys deny_file=.ssh chroot_local_user=YES Remember to restart the **vsftpd** service after making changes to the configuration file for them to take effect. 設定を変更した際は、それを反映するために **vsftpd** サービスを再起動する必要があります。 With this configuration, the user will be restricted to its root directory (''/var/spool/pandora/data_in'' in the case of the ''pandora'' user). The user will be able to make transfers via FTP (send files), **but will not be able to list files**. これらの設定により、ユーザはそのルートディレクトリ (''pandora'' ユーザの場合は ''/var/spool/pandora/data_in'' に限定されます)。 ユーザは FTP 転送を実行してファイルを送信できますが、**ファイルの一覧は見ることができません**。 Try to log in with the pandora user in the FTP, change directory and list files; if it does **not** succeed, the configuration will have been successful. FTP でユーザ pandora を使用してログインし、ディレクトリの移動とファイル一覧の取得を試してみてください。できない場合は、正しくセットアップができています。 [[ja:documentation:start|Pandora FMS ドキュメント一覧に戻る]]