Lightsail add user for SSH/SFTP access

Lightsail comes with an admin account but you don’t really want to give this to third parties if they require access for support. This is how to create (and remove) additional accounts.

Refer to https://community.bitnami.com/t/how-do-i-provide-temporary-access-to-sftp-phpmyadmin-on-aws-lightsail-lamp-stack/52475/2

First, use PuTTYGen to create key pair. The private key will be a .ppk file and the public key will be copied from the text area of the GUI into a .pub file. Save these files in a safe location.

Copy the .pub file to bitnami home directory on host.

https://winscp.net/eng/docs/ui_puttygen#authorized_keys

Refer to https://docs.bitnami.com/bch/faq/#step-2-option-b-allow-the-new-user-to-log-in-using-the-bitnami-account

Use Step 2 (Option A), substitute USERNAME for the account to be created.

sudo useradd -s /bin/bash -o -u `id -u` -g `id -g` USERNAME
sudo mkdir ~USERNAME/ 
sudo cp -rp ~bitnami/.ssh ~USERNAME/
sudo cp -rp ~bitnami/.bashrc ~USERNAME/
sudo cp -rp ~bitnami/.profile ~USERNAME/
cat USERNAME.pub >> /home/USERNAME/.ssh/authorized_keys

If they need administrator access

sudo usermod -G bitnami-admins USERNAME

Then follow instructions for log in using either ssh or SFTP.

https://docs.bitnami.com/aws/faq/operating-servers-instances/upload_files/#using-an-ssh-key

To remove user account

sudo userdel USERNAME -f
id USERNAME
1,583 views

Need help? Let me take care of your IT issues.

Share this page

Scroll to Top