=== denningsrogue4 is now known as denningsrogue === jelly-home is now known as jelly === markthomas_ is now known as markthomas [19:05] is there a way to kill someone off of a ssh? [19:14] MIF: a) Remove their access, and b) Kill their existing sshd kill child process(es) [19:15] Hmm, one too many kill there I think. [19:15] I don't need to remove the access because I just need to lock my self off of my server during certain hours [19:17] Even easier then. [19:17] Anyway, something like this ought to do the trick [19:17] what do I have to do for that? [19:17] pkill -u USERNAME sshd [19:20] how would I put this into a script? [19:21] you might prefer a script that is executed at a specific time every day that locks your user at the system level, and then a second script later on that unlocks your user. [19:21] but that's... tricky in itself [19:21] it'd also prevent you direct access via console too :P [19:21] how would I do that? [19:23] well there's one other way i can think of that'd work but it'd block all logins. script to disable: pkill -u USERNAME sshd; usermod --shell /usr/sbin/nologin USERNAME [19:23] ok [19:23] script to enable: usermod --shell /bin/bash USERNAME [19:23] but again this is UNTESTED [19:23] and you still need to crontab each of these for the root user [19:23] ok, I am going to spin up a test user [19:25] This account is currently not available. [19:25] it works [19:27] yep now test the enable script [19:27] and then crontab these `sudo crontab -e` and set the times you need for it to disable/kill SSH sessions and lockout the user. [19:27] (it also blocks SSH key auth which is why it's a decent solution) [19:28] but i would suggest that you should just exercise self restraint ;) [19:28] that is kinda hard for me to do, and my grades are showing it [19:33] how can I check the shell a user is set to? [19:38] first install `finger` - `sudo apt install finger`. Then this can get it: `finger USERNAME | grep -oP 'Shell: \K.*'` [19:38] replace USERNAME with the target user [19:38] ok [19:40] alternatively you can try and grep through `/etc/passwd` for the user. Example: `cat /etc/passwd | grep teward` returns "teward❌1000:1000:Thomas Ward,,,:/home/teward:/bin/bash" - username : password (X means it's in a different location) : default UID : default GID : user details of some sort : home directory : shell [19:40] alternatively you can try and grep through `/etc/passwd` for the user. Example: `cat /etc/passwd | grep teward` returns "teward:1000:1000:Thomas Ward,,,:/home/teward:/bin/bash" - username : password (X means it's in a different location) : default UID : default GID : user details of some sort : home directory : shell [19:40] hate weird symbols >.< [19:40] the final one is the shell but finger kind of reads half the info first. [19:41] do you think it would be easier if I set the output to a variable or directly in the if then statement? [19:41] I think I am going to stay with finger [19:41] what if statement [19:41] you're asking for solutions then referencing things that we haven'tseen :p [19:42] sorry, I was asking for a script I am writing to lock my self out of the server, so the first time it ran it will lock me, the second time it would unlock me, the third time it would lock me, ect. [19:45] don't try and do it with only one scritp [19:46] do it with two different scripts [19:46] Ok [19:46] one for lockout one for unlock [19:46] saves you the logic headaches [19:46] AND you can better audit when each script is ran [19:46] rather than trying to run a single script and program the proper logic in [19:46] Ok [19:46] sometimes the complexity of doing everything in one script is **too** much for simple things :p [19:47] Ok [19:50] isn't pam_time supposed to take care of all that? (man pam_time) [19:51] ah forgot about that but it requires configuration in /etc/security/time.conf and I don't have examples to block it on ssh only console access [19:51] but that's in `man time.conf` not `man pam_time` [19:54] would pam_time allow me to login via keyboard? [19:54] I would prefer a way to get into my server if needed [19:58] I guess that depends where you include pam_time in the other pam modules, for example in /etc/pam.d/sshd [19:58] ok [19:58] But I have not used it myself, it was just an idea [19:58] Ok [19:59] anyone who uses pam_time, would this work? sshd;tty*;nathaniel;Wk0840-1700 [20:10] MIF: by 'login via keyboard' you mean directly on the device's console? [20:10] yes [20:10] because that's a 'console' time control, if you don't have such a control it wont' block console access [20:11] ok [20:11] I just need to block ssh access === denningsrogue2 is now known as denningsrogue