/srv/irclogs.ubuntu.com/2022/02/02/#ubuntu-server.txt

=== amurray_ is now known as amurray
kb8unHi, I am new to IRC. I asked the question below to #openssh but I think the question relates more to the how gid/uid and permission works in linux system so I will repeat the question below, if I may.05:14
kb8unI have just set up sftp on ubuntu server 20.04 and followed the instruction below:05:14
kb8unhttps://linuxhint.com/setup-sftp-server-ubuntu/05:14
kb8unI've added user account 'user1' under group 'sftp' but when I log into the sFTP using 'user1' account, I can also see the user account folder of the admin - 'sftp_admin'.  I'm trying set it up so any new user that I add can only see their account.05:14
kb8un```bash05:14
kb8unsftp_admin@sFTP-vm001:~$ id sftp_admin05:14
kb8unuid=1000(sftp_admin) gid=1000(sftp_admin) groups=1000(sftp_admin),4(adm),20(dialout),24(cdrom),25(floppy),27(sudo),29(audio),30(dip),44(video),46(plugdev),117(netdev),118(lxd)05:14
kb8unsftp_admin@sFTP-vm001:~$ id user105:14
kb8unuid=1001(user1) gid=1001(sftp) groups=1001(sftp)05:14
kb8unsftp_admin@sFTP-vm001:~$ ls -l /home05:14
kb8untotal 805:14
kb8undrwx------ 3 eurus      sftp       4096 Feb  1 22:02 user105:14
kb8undrwxr-x--- 4 sftp_admin sftp_admin 4096 Feb  1 23:55 sftp_admin05:14
kb8un```05:14
kb8unThis is the "tail" of the file `/etc/ssh/sshd_config` file:05:14
kb8un```config05:14
kb8un# override default of no subsystems05:15
kb8unSubsystem sftp/usr/lib/openssh/sftp-server05:15
kb8un# Example of overriding settings on a per-user basis05:15
kb8un#Match User anoncvs05:15
kb8un#X11Forwarding no05:15
kb8un#AllowTcpForwarding no05:15
kb8un#PermitTTY no05:15
kb8un#ForceCommand cvs server05:15
kb8unMatch group sftp05:15
kb8unChrootDirectory /home05:15
kb8unX11Forwarding no05:15
kb8unAllowTcpForwarding no05:15
kb8unForceCommand internal-sftp05:15
kb8un```05:15
kb8unif there is a document url that I need to go through, please leave me a link.  I appreciate your help in advance.05:15
=== kb8un is now known as k8yun
cpaelzergood morning06:13
k8yunmorning07:08
=== ravage_ is now known as Ravage
kanashiroone step away from ruby-defaults migration14:42
=== genii-core is now known as genii
=== SoniEx2 is now known as Soni
k8yunMy sftp setup is having some issues.  What permission do I need to give 'client1' so that `client1' can only see their account when they login to the sftp?  "ls /home -la" output can be seen here: http://pastie.org/p/789lnnbOCPN9KAeCpB4JP717:55
sdezielk8yun: to completely hide stuff, you'd need to use OpenSSH's `ChrootDirectory` directive18:05
k8yunsdeziel: I have `ChrootDirectory "/home/$USER"` iin the `/etc/ssh/sshd_config` file but when trying to connect I get: 18:18
k8yunAuthentication log (see session log for details):18:18
k8yunUsing username "client1".18:18
k8yunAuthentication failed.18:18
patdk-lapyou have to be double deep to do chroot in ssh to hide18:18
patdk-lapit's kindof annoying18:19
sdezielk8yun: IIRC, the ChrootDirectory needs to be writable by root alone so you'd need to have something like `ChrootDirectory /srv/sftp-chroot/%u` and then inside `/srv/sftp-chroot/%u` you can create a subdirectory writable by `%u`18:19
sdezielk8yun: I typically use this coupled with `ForceCommand internal-sftp -d uploads` which changes the connecting client to `/srv/sftp-chroot/%u/uploads` upon connection so they can directly do their thing without needing to `cd` anywhere18:22
k8yunI thiiink I am following... that command `ForceCommand internal-sftp -d uploads` -- is this going inside of the config file?18:24
sdezielk8yun: that goes in /etc/ssh/sshd_config18:26
sdezielk8yun: once properly setup, client1 will only see "/uploads" and what's under it, the rest of the filesystem will be inaccessible/invisible to him/her18:27
sergiodjcpaelzer: slurm-wlm/armhf required a test retrigger against freeipmi, and it passed.  memcached/ppc64el required a build retrigger, and it passed too.18:27
k8yunsdeziel: thank you.  I will start implementing it and provide feedback in 15 min.18:28
sdezielk8yun: you are welcome18:29
k8yunsdeziel: I ran through configuration changes but still having some prob.  Details: https://privatebin.net/?69cbbeb65ce84951#H2u5yb23mmmoWGJbQF4vMQvBWwvsvK1d8hWqcaNiCSUF19:58
sdezielk8yun: maybe check the sshd logs?20:00
k8yunoutput of `tail -20 /var/log/auth.log` > https://privatebin.net/?731b1f09a3522c79#EiADGcfeUk3uoU4ZCbiGeB6NBQjcjzgqFfewpgK1uPNi20:07
sdezielk8yun: the log says the permission is wrong, try `sudo chmod 0700 /home/client1`20:08
sdezielk8yun: unrelated to the problem at hand but I'd advise against using password authentication if at all possible ;)20:09
k8yunwhat's the alternative? passphrase?20:10
sarnoldkeys20:10
sdezielk8yun: this ^, to learn how to use public key authentication you can check https://en.wikibooks.org/wiki/OpenSSH/Cookbook/Public_Key_Authentication#Basics_of_Public_Key_Authentication20:12
k8yun> logged to my todo list to tackle once the original issue is resolved20:13
k8yunI had permission of "770" before but I ran chmod once again on the folder, but still having issues with connecting from client.  Maybe restart the vm?20:14
sdezielk8yun: do you still see the `fatal: bad ownership or modes for chroot directory "/home/eurus"` error?20:15
cpaelzerthanks sergiodj, seems that were two easy unblocks 20:16
sdezielk8yun: also, the username "eurus" doesn't match "client1" but maybe you're trying to obfuscate the username?20:17
k8yunyes20:18
k8yun:(20:18
sergiodjcpaelzer: yep, all good now.20:18
k8yunpoorly executed20:18
sarnoldk8yun: throw this on your reading backlog :) https://blog.powerdns.com/2016/01/18/open-source-support-out-in-the-open/20:19
sdezielk8yun: I've retired my last SFTP server long ago, give me some time and I'll cobble one up to test it out20:23
patdk-lapdamn, I'm in violation of that .de court issue reading that website20:23
k8yun(logged)20:24
patdk-lapbut not with google, so I suppose all is fine20:24
sdezielk8yun: worked for me in a test container named sftp, see https://termbin.com/a06m20:57
cokepatdk-lap: just use a German cloud 20:58
k8yunsdeziel: Does the indentation matter following "Match Group ubuntu"?21:15
sdezielk8yun: I don't think so (just re-read the man page) but I've always used them21:17
k8yunthe only other difference, other than the indentation (which I agree won't matter, but I am going to match yours soon just to be sure), is having the permissions.  You're using 655.21:18
k8yun*755 I meant21:19
k8yunalso, I have "client1:sftp" for the ownership, whereas yours has "ubuntu:ubuntu".  I am going to match yours and see where the disparity is.21:20
sdezielk8yun: sigh, the `sudo chmod 0700 /home/client1` was wrong it seems, make it `0755` and it should work21:22
k8yunlet me give 'er21:23
sdezielk8yun: it seems sshd is overly paranoid and as soon as the group has write access, it bails, even if the dir is owned by root:root21:24
k8yunsdeziel: made changes from 0700 to 0755 and now works like a charm.  It's nice to know your finding on the last stmt.  21:27
k8yunThank you sir for guiding me through it!21:28
sdezielk8yun: my pleasure. If you look carefully, you'll see I've setup the ubuntu user to use key authentication with /home/ubuntu/.ssh owned by root so that the user in question cannot add other keys21:28
=== CodeMouse92 is now known as Guest1476
k8yunmakes sense and very nicely configured.21:34
=== Guest1476 is now known as CodeMouse92
k8yunsdeziel: Now, I'll pay my dues, and go through the links you've provided earlier.  Have a good rest of your day!21:36
sdezielk8yun: great, let us know if you have questions about SSH public key authentication21:37
k8yunyeah, I'm sure I will have questions -- :)21:39
petohi, can someone help me? i set up web server with postfix, i can send emails, but no receive? i dont know why, i use imap ans stmp21:40
patdk-lapdunno, you have any info?21:40
petodont know, im little bit newbie in this, in mail.log no error or warning21:45
petobut i use stmp port 587. and on my public ip is this port closed, is this problem?21:47
cokeprobably should go with 25 21:52
cokebut running a Mailserver is painful 21:52
sarnold25 is for server-to-server, 587 is submission, for clients to use when sending21:54
patdk-laprunning a mail server is the hardest service to do21:54
sarnoldand yes, it is painful. best to pay someone else to do it for you, if you can21:54
patdk-lapbesides all the stuff to run and keep running, and spam/virus, there is a big deal about reputation and blacklists, on if other people will even bother to accept your email21:55
patdk-lapnot sure why you expect an error or warning if you have a problem21:55
sarnoldfunny, I always tell people to read the logs straightaway :)21:56
sarnoldit works more often than not21:56
sarnoldthough, uh, running mailservers might be in the "go read about it for a few days first" territory21:56
patdk-lapyes, reading the logs is need21:57
patdk-lapbut it normal non-error/warning could still mean a failure or problem21:57
patdk-lapand is the case with most email issues21:57
sarnold"too broken to even log" :)21:57
patdk-lapas it *spools* mail21:57
patdk-lapthat is normally a case of domain name typo :)21:57
patdk-lapso the *error* could be a normal bounce email, and that could be delayed 7days by normal config21:58
ahasenackwaveform: I imported iniparser into git-ubuntu fyi, I see you have an open merge from debian (https://code.launchpad.net/ubuntu/+source/iniparser)22:02
ahasenackand tried to use git-ubuntu probably22:02
petoyes, i can pay for it, but i wanted to have my web and mail server, on my server22:02
petoand imap stmp CNAME on my domain ist set to old paid webhosting, it is needed?22:16
k8yunIf I have 'client1' and 'client2' accounts, and they can only see their own account, and yet I'd like 'sftp_admin' account to have access to their accounts, what's the best way to set up the permissions?22:32
sdezielk8yun: you can have all 3 as members of the sftp group and make the home directories (and uploads dir) of client1/2 readable by the sftp group22:33
k8yunbut I don't want client1 account to see client2 account.  22:35
k8yungiving read permission to the group will expose client1 account to client222:36
k8yunI think I need to create a separate group, say, 'client1group`, and have 'client1' and 'sftp_admin' added to the group.  Share the 'client1' folder shared with 'clientgroup'.  22:47
k8yunand repeat for client222:47
k8yunhmmm.... `Match group sftp` in the sshd_config is what's concerning me... need to do a bit more research...23:00
=== Rhys is now known as Guest7527
sdezielk8yun: the %u in the ChrootDirectory expands to the username meaning they will see a different root so client1 won't see /home/client223:19
k8yunsdeziel, good point23:22

Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!