Skip to main content

Stuck running sftp server on termux alpine for multi-user setup

The below is my journey trying to get multi-user sftp working using alpine on termux

pkg update && pkg upgrade
pkg install proot-distro openssh

proot-distro install alpine

proot-distro login alpine

apk update
apk upgrade

apk add openssh shadow sudo

apk add vim

vim /etc/ssh/sshd_config

Port 8022
PermitRootLogin no
PasswordAuthentication yes
Subsystem sftp internal-sftp

Match Group sftpusers
    ChrootDirectory /sftp/%u
    ForceCommand internal-sftp
    X11Forwarding no
    AllowTcpForwarding no

addgroup sftpusers

adduser user1
adduser user1 sftpusers

mkdir -p /sftp/user1/upload

chown root:root /sftp/user1
chmod 755 /sftp/user1

chown user1:sftpusers /sftp/user1/upload

How I run my server each time

pkill sshd
rm -f /etc/ssh/ssh_host_*
ssh-keygen -A
/usr/sbin/sshd -D -d -d -d

From another termux session

sftp -P 8022 user1@127.0.0.1

Connection reset by 127.0.0.1 port 8022
Connection closed

Some troubleshooting steps

mkdir -p /run/sshd
chmod 755 /run/sshd

grep sshd /etc/passwd
sshd:x:22:22:sshd:/dev/null:/sbin/nologin

This is where I am stuck
sshd debug output:

debug3: ssh_sandbox_init: preparing seccomp filter sandbox [preauth]
debug3: privsep user:group 22:22 [preauth]
debug1: permanently_set_uid: 22/22 [preauth]
permanently_set_uid: was able to restore old [e]gid [preauth]
debug1: monitor_read_log: child log fd closed
debug3: mm_request_receive: entering
debug3: mm_request_receive: monitor fd closed
debug1: mm_reap: child exited with status 255
debug1: do_cleanup
debug1: Killing privsep child 13150

Comments

Popular posts from this blog

Below the surface

This is a chapter from my eleventh book called Quotation Marks Sparks . __________ "You can't stop the waves, but you can learn to surf." - Jon Kabat-Zinn __________ I was looking at quotes that hit hard and this quote stood out to me. It seems mundane and obvious and often repeated. Life is about how we respond to the inevitable. It is not what happens to us but how we respond. I had to ask myself to dig deeper and look below the surface. Then I saw that when we surf we really become the waves. We become friends with the waves. The waves and us are the same. Further, the waves are created by us and in our heads. We can control the waves because who can surf all the time? Sometimes we just have to come to shore and build sand castles on shore. I asked my friend Gemini for feedback and he said that I was right, the Jon Kabat-Zinn quote initially seems like a simple call for resilience, but my deeper dive reveals profound layers. The idea that we can move beyond merely rea...

Nur al-Quran

It is 1037am and I have decided to write. I have been listening to the Quran more and more. I have also been trying to learn Arabic casually through social media. I am nearing the end of my second reading of the English Quran. The Quran is the word of God and God also tells us to follow the sunnah and life of the prophet (pbuh). The Quran is a miracle. The more I interact with the Quran, the more complete I feel. It gives my clarity. I have a purpose. I have goals. I have things I should be doing. Islam is a way of life and it builds character. Sometimes I listen to the Quran to forget about this world. This world is not my home. My home is in the hereafter and God willing in heaven. The more I draw closer to the Quran, the more beauty I see and hear and feel. Same goes to God. Same goes for the life of the prophet (pbuh). Same for Islam. If these are all the things I have in this world, I am happy. Reminds me of one of the duas I say daily. I am content with Allah as my Lord, Islam as...

Rain

This is a chapter from my latest book called (G)rains (o)f san(d)s. Learn more about the book here . Thank you God for the rain. It has just started raining here. I can hear the pitter patter on the roof. I can see the dimmed light through the window. The greenery in the yard is enjoying every chance of rain. The days have been extra hot this year. They say we are experiencing a super el nino in Trinidad. Given this every bit of rainfall feels special. Water is life. Without water there can be no life as we know it. Rain is part of the water cycle. Rain falling is like therapy. A calm state comes over my body. My mind relaxes. I appreciate my home and my shelter to keep me dry and safe. The rain is mentioned as a sign from God in the Quran and how it gives life to a lifeless land. The rain complements the sunshine as part of nature's balance. Sometimes we have to endure storms and floods and even droughts but there are lessons in these events. Community spirit is heightened and our...