How to Grant Access to a Specific File in cPanel Using FTP

When managing a website through cPanel, you may need to grant access to a particular file to a developer or team member. Instead of providing full access to your hosting account, you can use FTP (File Transfer Protocol) to restrict access to a specific directory or file. This guide will walk you through the step-by-step process of setting up and sharing access securely.
Step 1: Create an FTP Account in cPanel
To restrict access to a particular file, you first need to create an FTP account that has permission to access only the required directory.
How to create an FTP account in cPanel:
Log in to your cPanel by visiting
https://yourdomain.com/cpanel
.Navigate to the Files section and click on FTP Accounts.
Under Add FTP Account, fill in the following details:
Username: Choose a username for the FTP account.
Domain: Select the correct domain if you have multiple domains on your hosting.
Password: Set a strong password for the account.
Directory: Enter the directory path where the file is located. If you want to limit access to a specific folder, enter its path (e.g.,
public_html/config/devices/
).Quota: Set a limit for the account or leave it as unlimited.
Click Create FTP Account.
Step 2: Provide FTP Login Details to the Developer
Once the FTP account is created, share the following details with the developer:
FTP Host:
yourdomain.com
(or the server IP address)Username: (The FTP account username created in Step 1)
Password: (The FTP password you set)
Port:
21
(default FTP port)
These details will allow the developer to connect to the FTP server using an FTP client like FileZilla or Windows File Explorer.
Step 3: Developer Accessing the File via FTP
After receiving the FTP credentials, the developer needs to log in to the server and access the file.
Using FileZilla (Recommended Method)
Download & Install FileZilla from https://filezilla-project.org/download.php.
Open FileZilla and enter the credentials in the Quickconnect bar:
Host:
yourdomain.com
Username: FTP account username
Password: FTP password
Port:
21
Click Quickconnect.
On the right side (remote site), navigate to the directory where the required file is located.
Right-click on the file (e.g.,
viewDevicesdemo.php
) and choose Download to edit it locally.
Using Windows File Explorer
If the developer prefers Windows File Explorer instead of FileZilla:
Open This PC / My Computer.
In the address bar, type:
ftp://yourdomain.com
Press Enter.
Enter the FTP Username and Password when prompted.
Navigate to the required file (
viewDevicesdemo.php
) and copy it to their local system for editing.
Step 4: Editing & Uploading the Updated File
Once the developer has downloaded the file, they can edit it using a code editor like Notepad++, VS Code, or Sublime Text.
After making changes, upload the file back to the server:
In FileZilla:
Drag and drop the modified file back into the remote server directory.
When prompted, choose Replace to overwrite the old file.
In Windows File Explorer:
Copy the modified file from the local computer.
Paste it back into the FTP folder, replacing the existing file.
Step 5: Testing the Changes
After the file has been updated, verify that the changes are working correctly.
Open a web browser and enter the file’s URL:
https://yourdomain.com/config/devices/viewDevicesdemo.php
Check if the changes are reflecting properly.
If changes are not visible, clear your browser cache by pressing
CTRL + Shift + R
.
Step 6: Secure the File (Optional but Recommended)
To restrict access further and enhance security, use .htaccess rules.
Restrict access to a specific IP address:
Create or edit the .htaccess
file in the directory where the file is stored and add:
<Files "viewDevicesdemo.php">
Order Deny,Allow
Deny from all
Allow from 123.456.789.000
</Files>
Replace 123.456.789.000
with the authorized user’s IP address.
Change File Permissions
To prevent unauthorized modifications, set the file permissions to 644:
Go to cPanel → File Manager.
Locate the file.
Right-click → Permissions.
Set the value to 644 (Read & Execute only).
Conclusion
Granting access to a specific file in cPanel using FTP ensures that only authorized users can view or modify important files without exposing the entire website. By following the steps above, you can create a restricted FTP account, provide secure access to developers, and ensure safe file management.
For additional security, always use strong passwords, restrict IP access, and keep a backup of critical files before making any modifications.
If you have any questions or run into issues, feel free to comment below!
Subscribe to my newsletter
Read articles from Payal Porwal directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Payal Porwal
Payal Porwal
Hi there, tech enthusiasts! I'm a passionate Software Developer driven by a love for continuous learning and innovation. I thrive on exploring new tools and technologies, pushing boundaries, and finding creative solutions to complex problems. What You'll Find Here On my Hashnode blog, I share: 🚀 In-depth explorations of emerging technologies 💡 Practical tutorials and how-to guides 🔧Insights on software development best practices 🚀Reviews of the latest tools and frameworks 💡 Personal experiences from real-world projects. Join me as we bridge imagination and implementation in the tech world. Whether you're a seasoned pro or just starting out, there's always something new to discover! Let’s connect and grow together! 🌟