setting up a custom BBS reddit / bbs ---------------------------------------------------------------------- athlaknaka · 2020-02-17 18:50 hi /r/bbs! First post here, nice to meet y'all! I'm very new at this, and I was wondering how I could implement a very simple(?) idea. I would like to serve a single CLI app via SSH. I know C, so I'm able to code the "CLI app" part. For the sake of simplicity, let's say my program just asks for your name, and then greets you with Hi, yourname!. What I'd like to accomplish is to present this program on ssh login. So that a remote user, upon sshing ssh user@serveripaddress would be presented with such program. Of course I'd like it to work with only one "user", so I can still ssh to let's say admin@serveripaddress and have a regular ssh terminal there. So one can say I'd need a super-minimal bbs server? Basically something that just starts a specific program for a specific user and prevents them doing anything else. Does it make sense? I'm pretty convinced it's entirely possible, but I'm not sure what's the best way, should I use a BBS software and just strip it down of all functionalities and just make it run my CLI program? What would be the best BBS software for this? Or should I do it directly from my code with something like libssh? I'm not sure libssh can handle all the necessary parts, can it? Thanks a lot in advance and sorry if this sounds like a very lame-noob question :) ---------------------------------------------------------------------- unsignedmark · 2020-02-17 18:58 This is very simple and easy to do. Basically you just set the shell of the user in question to your own program. That way, your program will be launched whenever the user logs in, instead of a “normal” shell like bash or zsh. When your program exits, the user will be logged out. This works both over ssh, local login and telnet. To set the users shell, on most Linux distros, you just edit the /etc/passwd file. Hope that helps. ---------------------------------------------------------------------- unsignedmark · 2020-02-17 19:00 And here’s a few other ways if you’re don’t want to edit the passwd file directly: https://www.tecmint.com/change-a-users-default-shell- in-linux/ ---------------------------------------------------------------------- athlaknaka · 2020-02-17 19:18 yes!! THIS! that was fast, thanks a lot! just to give a little something back: grep username /etc/passwd ## check the user exists-check their current shell sudo usermod --shell /path_to_my_custom_program username grep username /etc/passwd ## to check the change also, little bonus: create .hushlogin in the user's home dir to disable the default ssh greeting cd /home/username ## go into the user home directory sudo touch .hushlogin again, thanks a lot! I knew there had to be a straightforward way to do this! ---------------------------------------------------------------------- unsignedmark · 2020-02-17 19:20 Glad it helped you! Ah, nice, I learned something as well, didn’t know about .hushlogin, so thanks for sharing that! ---------------------------------------------------------------------- thatpragmaticlizard · 2020-02-17 19:32 I've modeled this idea several times and had ideas/concerns similar to yours. Custom shells for BBS can be done and I don't think there's anything wrong with it. I just simply ran out of time and have a hard time finding more. Good luck! ---------------------------------------------------------------------- athlaknaka · 2020-02-17 19:40 yeah, as what I want to do is very simple, it's easier for me to write a few lines of C instead of using a full-fledged BBS software, learning the setup process and then basically disabling all of its functions! ---------------------------------------------------------------------- denzuko · 2020-02-17 22:45 wow.. ok so lots to decompress there; the basics of it seems you want to use standard unix / linux user experiences but have it run a simple "bbs program" on login via ssh? not really hearing anything here about doors, message boards, echomail (email/pm), or file transfers. Speaking from experience when I actually built this in the late 90s; If all one is looking for menus then a simple dialog script would work wonders. Now with that setup if one is wanting to do message board there's a few options but most unix like would be using ifcico and ifgate. This would also require one to use sendmail and inn nntp server but also opens up things like uucp and fidonet style networks. But if one is wanting something out of the box try looking at [http:// www.ivarch.com/programs/mconv.shtml](http://www.ivarch.com/programs/mc onv.shtml) or syncronet/mystic. the former works with unix systems (libpam, ssh, ...) while the others where ported from dos/windows machines so they're standalone and don't follow posix standards. ---------------------------------------------------------------------- denzuko · 2020-02-17 22:49 I wouldn't go that far; most modern linux systems execute tasks in the background as a user and have gone so far off the posix path they actually \*expect the shell to be /bin/bash\*. This even includes a lot of forking programs. Better to symlink the user's \~/.login file to the actual bbs/menu script instead and use the \~/.logout to clean up the environment. Best thing about this is one can keep these in /etc/skel so any new bbs users added to the machine automatically get these files. ---------------------------------------------------------------------- denzuko · 2020-02-17 22:57 ok so not my original codebase but a good launching point: [https://bash.cyberciti.biz/guide/A\_menu\_box](https://bash.cyberciti .biz/guide/A_menu_box) ---------------------------------------------------------------------- athlaknaka · 2020-02-19 11:10 not sure about the part " most modern linux systems execute tasks in the background as a user and have gone so far off the posix path they actually *expect the shell to be /bin/bash*. This even includes a lot of forking programs." For what I see, changing the shell did it. When a user logs in only the script does execute. And I control what files can be accessed, giving their ownership to my "host" user, or not. (at the moment the host user owns nothing) The ~/.logout thing is interesting tho, it might come in handy to clean up in case my script is exited abruptly or ends prematurely. Still not at that level of complexity, but could eventually get there. Thanks!