Score:0

Logging via sftp into a custom directory

dk flag
Sig

I'm trying to set up a custom root directory (/sftp/root) for an SFTP user. I have tried the two solutions I found around, but neither seems to work.

With the "default" /etc/ssh/sshd_config

Match User sftpuser
    PasswordAuthentication yes
    X11Forwarding no
    AllowTcpForwarding no
    PermitTunnel no
    AllowAgentForwarding no
    ForceCommand internal-sftp

I logged (as expected) into the home directory.

sftp> pwd
Remote working directory: /home/sftpuser

First, I tried to define the -d option.

Match User sftpuser
    PasswordAuthentication yes
    X11Forwarding no
    AllowTcpForwarding no
    PermitTunnel no
    AllowAgentForwarding no
    ForceCommand internal-sftp -d /sftp/root

But the outcome was the same.

sftp> pwd
Remote working directory: /home/sftpuser

Then, I tried the ChrootDirectory

Match User sftpuser
    PasswordAuthentication yes
    ChrootDirectory /sftp/root
    X11Forwarding no
    AllowTcpForwarding no
    PermitTunnel no
    AllowAgentForwarding no
    ForceCommand internal-sftp

With the following permissions

ubuntuuser@inlab123:/$ ls -l
drwxr-xr-x   3 root root       4096 Jun 26 08:47 sftp

ubuntuuser@inlab123:/$ ls -l /sftp
total 4
drw-rw-rw- 2 sftpuser sftpuser 4096 Jun 26 09:16 root

But I got

Connection to 101.0.6.769 closed by remote host.
Connection closed

Finally, I tried

Match User sftpuser
    PasswordAuthentication yes
    ChrootDirectory /sftp
    X11Forwarding no
    AllowTcpForwarding no
    PermitTunnel no
    AllowAgentForwarding no
    ForceCommand internal-sftp -d /root

with the following outcome.

sftp> pwd
Remote working directory: /

What am I missing here?

ws flag
`drw-rw-rw-` directories need the 'x' permission to access.
dk flag
Sig
Thanks for you reply.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.