<img src={require('./img/7081413.jpg').default} alt="Access Denied warning with a locked padlock, error symbols, and malware icons—representing SFTP permission issues on a Bitnami server." width="500" height="400"/> <br/> You're not alone if you've ever attempted to upload a file to your Bitnami server using SFTP and run into the dreaded `Permission denied` error. When the person you're connecting as lacks the required write rights for the target directory, this problem frequently occurs. To help you troubleshoot and resolve this issue so you may resume your job, here is a simple instruction. ## Recognizing the Issue Usually, the error looks something like this: ```bash /path/to/target/directory/yourfile.ext" is the remote open function. Denied permission ``` This occurs because your SFTP account lacks write permissions to the directory you're attempting to upload to, which is held by a user (or group). This is particularly typical for WordPress or other application-related folders on Bitnami servers. ## First step: Verify Permissions <img src={require('./img/6322675.jpg').default} alt="Illustration of a person entering an OTP code for two-factor authentication, representing secure login verification with a shield icon for data protection." width="500" height="400"/> <br/> Go to the target directory first by SSHing into your server. To check its permissions, use the `ls -ld` command: ```bash ssh -i LightsailDefaultKey.pem bitnami@yourserver ls -ld /path/to/your/directory ``` This is what you'll see: ```bash drwxr-xr-x 2 root root 4096 Nov 9 12:00 ai1wm-backups ``` In this instance, `root` is the owner of the directory, and only the owner is able to write. Your upload failed because of this. [Learn more about Linux file permissions](https://www.gnu.org/software/coreutils/manual/html_node/File-permissions.html) ## Second Step: Modify Permissions Temporarily You can let anyone write to the directory if you don't mind temporarily lowering the directory permissions: ```bash sudo chmod 777 /path/to/your/directory ``` Next, use SFTP to upload your file: ```bash sftp -i LightsailDefaultKey.pem bitnami@yourserver cd /path/to/your/directory put yourfile.ext ``` Revert the permissions to a more secure level after the upload is finished: ```bash sudo chmod 755 /path/to/your/directory ``` [More details on chmod](https://linux.die.net/man/1/chmod) ## Step 3: Use `scp` with `sudo` <img src={require('./img/5063183.jpg').default} alt="Illustration of a person sitting with a laptop in front of a large screen showing a software update in progress, with cloud upload and refresh icons representing system updates and synchronization." width="500" height="400"/> <br/> Another choice if you don't want to change the directory permissions is to upload the file to a temporary directory, such as `/tmp`, using `scp` (secure copy), and then use `sudo` to move it to the target directory. ### Transfer the file to `/tmp`: ```bash scp -i LightsailDefaultKey.pem yourfile.ext bitnami@yourserver:/tmp ``` ### Move the file to the target directory: ```bash ssh -i LightsailDefaultKey.pem bitnami@yourserver sudo mv /tmp/yourfile.ext /path/to/your/directory/ ``` ## Best Practices - **Use the Least Privileges Required**: To avoid security issues, always reverse directory permissions after finishing an operation. - **Verify Control**: If this is a routine task, think about giving the Bitnami user control of the directory: ```bash sudo chown bitnami:bitnami /path/to/your/directory ``` - **Automate Using Scripts**: If you frequently perform this task, a straightforward script can help you save time and effort. [Bitnami Documentation](https://docs.bitnami.com/) has additional guidance on managing permissions effectively. ## Conclusion That's it! You may easily upload your files and get around the `Permission denied` problem by changing permissions or by utilizing `scp` with `sudo`. This technique is applicable to any Linux-based system with comparable permission problems, not just Bitnami servers. If you're looking for [cloud deployment](https://nife.io), check out what Oikos by [Nife](https://nife.io/oikos/features) has to offer.