概要: You can give customers the ability to create scheduled tasks that run commands on the server. In Plesk for Linux, the shell being used determines which areas of the file system scheduled tasks have access to. By default, access is limited to the customer's webspace. However, Plesk administrator has the ability to change that.

In this topic, you will learn how to set the default shell for scheduled tasks, how to set a custom shell for an individual subscription, and also how to allow a customer to set a custom shell for their subscription. You will also learn how to prevent customers from using the "Run a Command" scheduled tasks.

Note: If you are not familiar with the concept of Linux shells, we recommend learning more before changing the settings described in this topic.

スケジュール済みタスクの実行に使用されるシェル

「コマンドを実行」スケジュール済みタスクに使用されるシェルは、契約のシステムユーザに紐付けられています(つまり、ある契約の下で作成されるすべてのスケジュール済みタスクで、同じシェアが共有されます)。デフォルトで、このシェルは、サーバ設定に構成されており、サーバのすべての契約で使用されるデフォルトシェルと一致します。ただし、このルールには 2 つの例外があります。

いずれの場合も、契約の下で作成された「コマンドを実行」スケジュール済みタスクは、デフォルトシェルではなくカスタムシェルを使用するようになります。

異なるシェルを使用する理由

デフォルトでは、/bin/bash (chrooted) シェルがスケジュール済みタスクのデフォルトシェルとして構成されています。これにより、スケジュール済みタスクで実行されるコマンドは、契約に紐付けられたウェブスペース内のファイルにのみアクセスできます。これは、顧客がスケジュール済みタスクを使用してサーバの動作を妨害したり、Plesk 管理者や他の顧客に属するファイルに不正アクセスしたりできないようにする重要なセキュリティ対策です。

注釈: This setting affects all subscriptions on the server, including those owned by the Plesk administrator. It does not affect the scheduled tasks created by the Plesk administrator in Tools & Settings > Scheduled Tasks (Cron jobs) (under "Tools & Resources") that are configured to run under the root user.

スケジュール済みタスクのデフォルトシェルを変更することが役に立つ主な理由は、サーバ上のすべてのユーザが、サーバのファイルシステム全体にアクセスできるスケジュール済みタスクでコマンドを実行できるようにしたい場合です。

サーバを誰とも共有していない場合や、他のテナントを信頼している場合には、スケジュール済みタスク用に非 chroot シェルを選択できます。スケジュール済みタスクに非 chroot シェルを使用したい場合に、どのシェルを選ぶべきかわからなければ、/bin/bash を選択してください。

共用ホスティングサーバでは、スケジュール済みタスクのデフォルトシェルを /bin/bash (chrooted) のままにしておくことをお勧めします。顧客から非 chroot シェルを求められた場合、契約単位で 付与する ことができます。

警告: 顧客に /bin/bash (chrooted) 以外のシェルへのアクセス権を付与すると、この顧客はバイナリを実行し、自らに属していないファイルやデータにアクセスできるようになります。これはセキュリティ上のリスクとなり、サーバの悪用につながる可能性があります。

スケジュール済みタスクにデフォルトシェルを設定する

To set the shell that will be used to run all "Run a Command" scheduled tasks by default, go to Tools & Settings > Scheduled Tasks (Cron jobs) (under "Tools & Resources") > Settings and select the desired shell from the menu.

image select shell

あるいは、サーバに ssh ログインして、以下のコマンドを実行します。

plesk bin server_pref -u -crontab-secure-shell "<shell>"

ここで <shell> は、必要なシェルです。例:

plesk bin server_pref -u -crontab-secure-shell "/bin/bash"

「コマンドを実行」スケジュール済みタスクの使用を禁止する

サーバ上で悪意ある活動(スパム送信など)を実行するスケジュール済みタスクを顧客が作成した疑いがある場合、調査中はすべての「コマンドを実行」スケジュール済みタスクを無効にしておくことができます。

Plesk サーバに ssh ログインし、以下のコマンドを実行します。

plesk bin server_pref -u -crontab-secure-shell "/bin/false"

これにより、スケジュール済みタスクのデフォルトシェルが /bin/false に設定されます。これにより、顧客が作成したすべての「コマンドを実行」スケジュール済みタスクが失敗するようになります。

注釈: Customers that have the permission to select a different shell can override this for their subscriptions by selecting a different shell.

個別の契約にカスタムシェルを設定する

個別の契約にカスタムシェルを設定するには、次の手順に従います。

  1. Go to Subscriptions, click the desired subscription, go to the "Hosting & DNS" tab, and then click Hosting.
  2. Select the desired shell from the "SSH Access" menu and click Save.

この契約のすべての「コマンドを実行」スケジュール済みタスクで、選択されたシェルが使用されるようになります。

顧客に対して契約へのカスタムシェルの設定を許可する

顧客に対し、この顧客が所有するいずれかの契約へのカスタムシェルの設定を許可するには、次の手順に従います。

  1. [契約]で必要な契約をクリックし、[カスタマイズ]をクリックします。
  2. [パーミッション]タブで、[ホスティング設定管理]チェックボックスと[プロバイダのポリシーをオーバーライドする潜在的に安全ではないウェブスクリプトオプションのセットアップ]チェックボックスをオンにして、[更新してロック]をクリックします。

This will give the customer the ability to select a different shell in Websites & Domains > "Hosting & DNS" tab > Hosting. If they do, all "Run a Command" scheduled tasks for their subscription will use the selected shell.

契約で使用されるシェルを確認する

ある契約の「コマンドを実行」スケジュール済みタスクで使用されるシェルを確認するには、次の手順に従います。

  1. Look up the username of the subscription's system user. Go to Subscriptions, click the desired subscription, go to the "Hosting & DNS" tab, click Hosting, and then look for the "Username" field.
  2. Plesk サーバに ssh ログインし、以下のコマンドを実行します。
crontab -u <system user name> -l | grep SHELL