Bobcares

How to Access WordPress Files on AWS EC2 via FTP

by | Aug 28, 2024

Learn how to access WordPress Files on AWS EC2 via FTP. Our WordPress Support team is here to help you with your questions and concerns.

How to Access WordPress Files on AWS EC2 via FTP

If you are running a WordPress site on an Amazon Web Services EC2 instance, you are likely to access its files directly. One of the best ways to do this is through SFTP (Secure File Transfer Protocol).

How to Access WordPress Files on AWS EC2 via FTP

SFTP is a secure version of FTP, using SSH to encrypt all data transfers. Unlike FTP, which sends data in plain text and is vulnerable to interception, SFTP encrypts both commands and data, providing a secure way to transfer files between a client and server.

The key differences between FTP and SFTP include:

  • SFTP encrypts all data, making it unreadable to unauthorized users, while FTP transfers data in plain text.
  • Also, SFTP uses secure methods like SSH keys, unlike FTP, which relies on less secure password authentication.
  • SFTP operates over a single port (usually port 22), simplifying firewall configurations and reducing security risks.

SFTP offers secure access to the server’s file system. Today, we are going to take a look at how to connect to our AWS EC2 instance using an FTP client.

Although we are using Cyberduck for this example, the instructions are applicable to other FTP clients like FileZilla as well.

An Overview:

  1. Requirements
  2. Step-by-Step Guide to Connecting via SFTP
  3. Troubleshooting File Upload Issues
  4. Security Benefits of Using SFTP

Requirements

Before we begin, we need to make sure we have the following:

  • An FTP client (e.g., Cyberduck, FileZilla)
  • The host address of the EC2 instance
  • SSH login credentials, including the private key file (.pem) used for authentication

Step-by-Step Guide to Connecting via SFTP

  1. First, open Cyberduck or the chosen FTP client from the applications menu.
  2. Then, click on the “Open Connection” icon, usually located in the top-left corner of the FTP client interface.
  3. In the connection dialog, switch the default protocol from “FTP” to “SFTP (Secure File Transfer Protocol)”.
  4. In the “Server” field, enter the address of our EC2 instance. It might look something like `ec2-15-223-95-15.ca-central-1.compute.amazonaws.com`. We can find our instance’s address in the AWS EC2 Dashboard under the “Public DNS (IPv4)” field.
  5. Then, enter the username from our login credentials. For example, if we used the “WordPress Certified by Bitnami and Automattic” AMI, the username might be `bitnami`.
  6. After that, click on the dropdown for “SSH Private Key.” If the private key is already added to the SSH agent using `ssh-add`, it should appear in the dropdown. If not, click “Choose…” to select the key manually from the file system, usually located in the `.ssh` directory.
  7. Furthermore, we can choose to save the private key in our macOS Keychain for easier access in the future. If we prefer not to, clear the “Add to Keychain” checkbox.
  8. Then, click “Connect.” If this is our first time connecting, we may see a pop-up asking us to verify the server’s fingerprint. Check the “Always” box and click “Allow.”
  9. Once connected, we will be in the default directory (`/home/bitnami`). Use the dropdown menu to navigate to the desired directory. For example, to access WordPress files, go to `/opt/bitnami/apps/wordpress/htdocs`.
  10. If the FTP client is configured with a text editor, we can edit files like `wp-config.php` directly by clicking the “Edit” button.
  11. Finally, click the “Disconnect” button to close the FTP connection.

Troubleshooting File Upload Issues

If we are running into issues while uploading plugins or themes via WordPress, it may be due to permission settings or other configuration problems. Here are some solutions:

  1. The default permission settings may prevent the `apache` user from accessing necessary directories. Run the following command to adjust permissions:

    sudo chown -R apache:apache /var/www/html

    After running this command, we should be able to upload themes, plugins, and updates.

  2. Alternatively, we can change the owner of the WordPress directory:

    sudo chown -R www-data:www-data /var/www/wordpress

  3. Then, add the following line to the `wp-config.php` file to enable direct file access:

    define('FS_METHOD', 'direct');

    If we are still having trouble, we have to check if the EC2 instance’s security group allows outbound traffic over port 443 (HTTPS).

  4. To quickly resolve permission issues, temporarily set the file permissions to a more open state:

    sudo chmod 777 -R /whole_wp_project

    After making changes, revert to safer permissions:

    sudo chmod 664 -R /your_whole_wp_project

  5. If we prefer to use FTP over SFTP, we need to set up and configure an FTP server on our instance. This involves:
    • Creating custom rules for ports 20-21 and other necessary ports in the EC2 firewall.
    • Also, installing and configuring an FTP server like `vsftpd`.
    • Creating and configuring an FTP user and updating the FTP settings in your `wp-config.php` file.

Security Benefits of Using SFTP

  • Ensures all data transferred is secure, protecting sensitive information from interception.
  • Furthermore, it uses stronger methods like SSH keys to prevent unauthorized access.
  • Operates on a single port, making it easier to secure.
  • Also, it meets regulatory requirements (like GDPR, HIPAA) for secure file transfers.

[Need assistance with a different issue? Our team is available 24/7.]

Conclusion

The above steps will allow us to access our WordPress files on an AWS EC2 instance securely and efficiently.

In brief, our Support Experts demonstrated how to access WordPress Files on AWS EC2 via FTP.

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF