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).
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:
- Requirements
- Step-by-Step Guide to Connecting via SFTP
- Troubleshooting File Upload Issues
- 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
- First, open Cyberduck or the chosen FTP client from the applications menu.
- Then, click on the “Open Connection” icon, usually located in the top-left corner of the FTP client interface.
- In the connection dialog, switch the default protocol from “FTP” to “SFTP (Secure File Transfer Protocol)”.
- 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.
- 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`.
- 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.
- 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.
- 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.”
- 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`.
- If the FTP client is configured with a text editor, we can edit files like `wp-config.php` directly by clicking the “Edit” button.
- 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:
- 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.
- Alternatively, we can change the owner of the WordPress directory:
sudo chown -R www-data:www-data /var/www/wordpress
- 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).
- 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
- 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