HTML
 Computer >> コンピューター >  >> プログラミング >> HTML

HTTP 認証でログイン ページをパスワードで保護する方法

HTTP 認証によるパスワード保護ログイン ページ: 6,000 万の WordPress Web サイトがあり、世界で最も人気のある Web サイト構築プラットフォームとなっています。 しかし、この人気には代償があります。 WordPress サイトでは、1 分間に 90,978 回のハッキングが試みられています。ハッカーが Web サイトに侵入するために採用するさまざまな方法がありますが、非常に一般的で広く使用されている方法の 1 つは、ブルート フォース攻撃と呼ばれます。このタイプの攻撃では、ハッカーがボットをプログラムして、認証情報からログイン情報を正しく推測しようとするため、WordPress のログイン ページを保護する必要があります。

ログイン保護に関する以前の投稿で、一意のユーザー名を考え出し、強力なパスワードを強制することについて説明しました.これはハッカー ボットをサイトから遠ざける効果的な方法ですが、セキュリティに関して言えば、サイトが安全であるという絶対的な保証はありません。 インターネットは決して安全な場所ではありませんでした。また、いくらセキュリティを強化しても十分ではありません。したがって、サイトを何層にも保護することは良いことです。 一意のユーザー名とパスワードは重要ですが、ログイン ページをロックすることもセキュリティに向けた重要なステップです。その方法の 1 つは、ログイン ページを HTTP 認証でパスワード保護することです。この投稿では、それを実現する方法を紹介します。

HTTP 認証とは?

HTTP 認証または HTTP 基本認証 (BA) は、ログイン ページへのアクセスを制限する技術です。簡単な例えを描くために、ウェブサイトを家と考えてください。メインドアはログインページです。人々が家に侵入しようとする可能性があるため、強力なロックが必要です。ロックはログイン資格情報を表します。メインドアの向こうには、家をさらに保護するフェンスがあります。同様に、HTTP 認証は、家に特別な保護レイヤーを提供します。 つまり、ログイン ページにアクセスしたい人は、最初に HTTP 認証 (フェンス) とログイン資格情報 (メイン ゲート) を通過する必要があります。

HTTP 認証でログイン ページをパスワード保護する方法 ?

WordPress サイトを HTTP 認証で保護するには、まず .htpasswd ファイルを生成する必要があります。次に、Web サイトの .htaccess ファイルに .htpasswd ファイルの場所を通知する必要があります。そして、それはあなたのログインページをロックダウンします.

.htpasswd ファイルの作成方法

この特定のファイルには、ログイン ページでアクセスするユーザーのユーザー名とパスワードを保存します。 本質的には、家を囲むフェンスに門があるようなものです。サイトへのアクセスを許可したい人だけに門の鍵を渡すことができます。 .htpasswd ファイルを作成する方法を見てみましょう。

新しい .htpasswd ファイルを作成するには、.htpasswd コマンド ライン ツールを使用する必要があります。オンラインで利用できるツールがいくつかあります。使用したいものが見つかったら、それを開いて、コマンド ラインで次のコードを記述します。

htpasswd -c .htpasswd ハリニ

このコマンド ラインでは、c は create を表し、harini は選択したユーザー名です。このコードを入力して Enter キーを押すと、このユーザー名に固有のパスワードを作成するよう求められます。心配しないで;パスワードは暗号化されます。

HTTP 認証でログイン ページをパスワードで保護する方法

ただし、既に .htpasswd ファイルがある場合は、新しいユーザー名とパスワードを追加するだけです。次のコマンドラインを書き留めることでそれを行うことができます:

htpasswd .htpasswd ラーフル

新しいファイルを作成していないため、ここで -c を使用していないことに注意してください。

HTTP 認証でログイン ページをパスワードで保護する方法

通常、.htpasswd ファイルは、username:encrypted_pa​​ssword のようになります。 So if the username is harini and the password is dummy123pass, then the .htaccess file would be:harini:$apr1$50r17zis$lNbFJs4rQFfkp4ToO2/ZS/

The password has been encrypted. This .htaccess file is essentially your HTTP Basic Authentication credentials.

In case, you don’t want to use a tool or don’t know how to; you can use a .htpasswd generator. Open this link, and you should be able to see a window like an image below.

HTTP 認証でログイン ページをパスワードで保護する方法

Type the username and password of your choice. There is an option to generate a random password too. Once done, hit the button that says Generate .htpasswd file. You should be able to see an output.

Modifying the .htaccess File

The .htaccess file is one of the most important files of your WordPress site. There are two things we’ll do with your .htaccess file. One, we’ll tell it what it needs to restrict and two, we tell it from where it could get the HTTP Basic Authentication credentials we just created in the steps above.

.htaccess is present in the public_html folder. To access it you will have to visit your web host account. Log in to your web host and go to a page called cPanel. There you should be able to find an option for File Manager. Select that, and a page will open, and in that page, you should be able to view the file.

HTTP 認証でログイン ページをパスワードで保護する方法

Sometimes .htaccess is hidden and may not appear in the public_html folder. When that’s the case, what you need to do is go back to the cPanel, and click on File Manager. A popup will appear where you’ll have to select ‘Show Hidden Files.’

HTTP 認証でログイン ページをパスワードで保護する方法

Next, you need download the file and then open it to add this code of line:

<Files wp-login.php>

AuthUserFile /path/to/.htpasswd

AuthName "Private access"

AuthType Basic

require valid-user

</Files>

A few things you need to keep in mind when inserting this code: AuthUserFile /path/to/.htpasswd – is the path to the .htpasswd file you just created. Make sure the path is correct. The term ‘valid-user’ tells the system any user who has been mentioned in the .htpasswd file with access to the login page. But if you want to be selective about who you grant access to, then instead of using ‘valid-user’, you can just mention the usernames.

After you are done, save it and upload it to the same place from where you downloaded it. And that’s it. The next time you try to access the login page, you’ll see a small window appearing asking you for specific login credentials.

Besides HTTPS authentication, we suggest that you also implement two-factor authentication, which will add another layer of security to your WordPress login page.

Also take a few more security measures like moving your site from HTTP to HTTPS, installing a security plugin, protecting the login page, etc. While protecting your login page is a great idea, there are other ways in which hackers can gain access to your website. We strongly suggest that you take a more holistic approach to security by following our guide on Complete WordPress Security.


  1. USB ペン ドライブをパスワードで保護する方法

    USB/ペン ドライブ/フラッシュ ドライブはポータブル デバイスであり、USB ポートを備えたあらゆるデバイスで読み取ることができます。 OTGアダプターが手元にあれば、スマートフォンでも使用できます。あるコンピューターから別のコンピューターに重要なデータを転送するタスクが簡単になります。その機動性のために、私たちは時々それを失う傾向があるため、機密データを失う危険があります.データの盗難を防ぐには、誰も介入できないように USB をパスワードで保護する必要があります。 メモリー スティックを保護するのは、Facebook や Instagram のアカウントをパスワードで保護するほど簡単で

  2. Excel ファイルをパスワードで保護する方法

    コンピュータを仕事や勉強に使用するかどうかに関係なく、Microsoft Excel スプレッドシートを使用したことがあるはずです。これは、Microsoft スイートに付属する基本的なオフィス ツールです。 Microsoft Office 365 でも Microsoft Office 2019 でも、どちらにも Excel が搭載されています。悪意のある人の手に渡る傾向があるため、ファイルよりもデータを保護する方法をこれ以上強調することはできません.誰かがそれをコピーしたり、ファイルに変更を加えたりする可能性があります。ファイルはオンラインまたはデバイス経由で Bluetooth 経由で