Skip to content

Instantly share code, notes, and snippets.

@mohamm6d
Created April 13, 2020 06:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mohamm6d/1303c4d9932f637e87e4f3fde2795ce3 to your computer and use it in GitHub Desktop.
Save mohamm6d/1303c4d9932f637e87e4f3fde2795ce3 to your computer and use it in GitHub Desktop.
Adding new user to SFTP bitnami
Create a new user in your system. This will create the directory /home/USERNAME/
sudo useradd -s /bin/bash -m USERNAME
Add USERNAME to the daemon groups
sudo usermod -G daemon USERNAME
Set the HOME environment variable for that user to the WordPress directory installation so when you SSH to your server using that USERNAME, it will be logged into that directory instead of /home/USERNAME. To do that, please add the following line at the end of the /home/USERNAME/.bashrc file
export HOME="/opt/bitnami/apps/wordpress/htdocs"
# Force moving to that new HOME directory
cd ${HOME}
Add the content of the user’s public key file to the /home/USERNAME/.ssh/authorized_keys file. In this example, the user’s public key is assumed to be in USERNAME.pub:
Copy
sudo mkdir -p /home/USERNAME/.ssh
cat USERNAME.pub >> /home/USERNAME/.ssh/authorized_keys
@naveenmisra
Copy link

naveenmisra commented Sep 4, 2020

Hi I have installed bitnami lamp on AWS lighsail.
everything works well. I am able to create a new user and do ssh and sftp.
when I SSH- I enter the correct directory.
When I do sftp, I enter in home directory. Do not not know why the behavior from sftp to ssh is different.
Also very important, the user can move up to the directory. export HOME="/opt/bitnami/apps/wordpress/htdocs"
I only want to force user to access ht docs and its sub-directories only.

Force moving to that new HOME directory ( it does not work)

cd ${HOME}

@samholguin
Copy link

Hi I have installed bitnami lamp on AWS lighsail. everything works well. I am able to create a new user and do ssh and sftp. when I SSH- I enter the correct directory. When I do sftp, I enter in home directory. Do not not know why the behavior from sftp to ssh is different. Also very important, the user can move up to the directory. export HOME="/opt/bitnami/apps/wordpress/htdocs" I only want to force user to access ht docs and its sub-directories only.

Force moving to that new HOME directory ( it does not work)

cd ${HOME}

You need to edit the sshd_config file to restrict SFTP access. Setting the HOME var only works for SSH

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment