Skip to main content

Check Access Logs on cPanel Hosting

Updated today

The .lastlogin file is a fundamental record in cPanel that stores information about the last access to the control panel. If you’re on shared hosting, this is the only log file you can access to verify who has logged in to your cPanel account.


📌 What is the .lastlogin file in cPanel?

The .lastlogin file is a text log that stores the last IP addresses that accessed your cPanel account and the date/time when the access occurred.

🔹 What is it for?

✔ Allows you to verify if the last IP that logged in is yours or if there’s suspicious activity.
✔ Helps detect unauthorized access to your cPanel.
✔ Useful for performing security audits on your hosting account.


🛠️ How to Access and Read the .lastlogin File in cPanel

📍 Step 1: Locate the .lastlogin File

  1. Log in to your cPanel account.

  2. Go to Files > File Manager.

  3. Open the “home” folder (your user’s root).

  4. Look for the .lastlogin file (if you don’t see it, enable the option to show hidden files).

  5. Right-click on .lastlogin and select View or Edit.


📍 Step 2: Interpret the File Content

The .lastlogin file contains records in the following formats:

192.168.1.18 # 2024-09-06 15:49:39 +0200 10.0.0.58 # 2024-09-13 15:56:29 +0200 200.21.10.119 # 2024-09-25 08:48:47 +0200

🧐 Explanation of Each Element:

  • 192.168.1.18 →IP that accessed cPanel.

  • 2024-09-06 15:49:39 → Access time.

You can get more information about each IP (country, approximate city, ISP) from this page:


🚨 How to Detect Suspicious Access in .lastlogin

If the IP registered in .lastlogin isn’t yours, it may indicate someone has accessed your cPanel without authorization.

🔴 Warning Signs:

⚠ The IP is unknown or from another country.
⚠ The access occurred at an unusual time.
⚠ You notice unexpected changes to your website or settings.

How to Check if the IP is Yours

  1. Visit ip.sered.net to see your current IP address.

  2. Compare it with the IP listed in .lastlogin.

  3. If the IP is different and suspicious, follow the security steps below.


🔐 How to Protect Your cPanel and Prevent Unauthorized Access

If you detect strange access in .lastlogin or simply want to increase your cPanel security, follow these recommendations:

🛡️ 1. Change Your cPanel Password

If you detected a suspicious IP in .lastlogin, change your password immediately:

  1. Go to cPanel > Preferences > Password & Security.

  2. Use a strong password (uppercase, lowercase, numbers, and symbols).

  3. Do not reuse passwords from other services.

You can also quickly change it with this guide:

How to Change Your cPanel Password Quickly | Sered S.L.


🛡️ 2. Enable Two-Factor Authentication (2FA)

This adds an extra layer of security by requesting an additional code from an app like Google Authenticator.

📍 How to Enable It in cPanel:

  1. Go to cPanel > Security > Two-Factor Authentication.

  2. Scan the QR code with Google Authenticator or Authy.

  3. Enter the generated code and confirm activation.

If you need help configuring it, check this guide:

🔹 Benefit: Even if someone gets your password, they won’t be able to log in without the 2FA code.


Conclusion

The .lastlogin file is your best tool within shared hosting to check the latest cPanel logins.

🔹 Check .lastlogin to know the last IP that logged in.
🔹 If you detect suspicious activity, change your password and strengthen security.
🔹 Enable Two-Factor Authentication (2FA).

🚀 Regularly monitoring .lastlogin will help you prevent unauthorized access and improve the security of your cPanel account.

Did this answer your question?