Setting up extra ftp account

October 23, 2018 1.6k views
Configuration Management Ubuntu 18.04

I am setting up an Ubuntu-LAMP droplet with SSH access. Now I want to provide someone else (S)FTP access to this droplet. But I don’t want to give him the SSH key. Instead I just want to give him a username and password that I can easily withdraw later on.

How can I do this?

3 Answers
unixynet October 23, 2018
Accepted Answer

You just need to add an account with useradd. This article has the steps in detail:

https://www.digitalocean.com/community/tutorials/how-to-enable-sftp-without-shell-access-on-ubuntu-16-04

Cheers

by Mateusz Papiernik
SFTP stands for SSH File Transfer Protocol. As its name suggests, it's a secure way of transferring files to a server using an encrypted SSH connection. In a standard configuration, the SSH server grants file transfer access and terminal shell access to all users with an account on the system. In this tutorial, we'll set up the SSH daemon to limit SFTP access to one directory with no SSH access allowed on per user basis.
  • Thank, it does part of what I want.
    I want to give some supplier access for technical support. So I want to give him full access to a complete website but not the rest of the server. Problem is that that way I cannot give him ownership as that would break the website. I tried to skip the chown step in the article but the result is that he can login with FTP but he then gets the message that the folders cannot be retrieved. How to solve this?

Hey friend,

Great question! You can have them generate their own SSH key and then add their public key to your authorizedkeys file on the droplet (/home/user/.ssh or /root/.ssh). If you need them to have root access, note that while you can remove their SSH public key from the authorizedkeys file at any time, there may be no way to know what backdoors they’ve left for themselves. Never let anyone you don’t trust in with root or sudo access.

Setting up a privileged user with only access to what they need makes more sense, but there’s no one size fits all instruction for doing it because every situation varies. For example, needing them to access a folder will be different than needing them to read/write a folder that is also able to be read/written by an active service.

Jarland

I followed the recipe that unixynet linked to. However, I am running into some obstacles. I want to give somebody access for technical support so he would need the full rights to a website (but not the other on this server). The example creates a special directory and gives the visitor its ownership but that is no option for me. I need to give full rights to something of which the visitor is not the owner.

What I did now was:

  • adduser visitor

And then I have adapted the /etc/ssh/sshd_config file by adding:

Match User visitor
ForceCommand internal-sftp
PasswordAuthentication yes
ChrootDirectory /home/mysite/public_html
PermitTunnel no
AllowAgentForwarding no
AllowTcpForwarding no
X11Forwarding no

I can connect in FTP with the user’s name and password but then it gives an error message that it cannot retrieve the folders

Have another answer? Share your knowledge.