2

I'm wondering if anyone has ever written a cron script that blocks ones remote access (specifically a linux email server that I access via alpine on my local linux machine over an ssh connection) over the weekend? I'd like to not rely on my own self-control nor do I have root privileges on the mail server.

I can imagine having a script that changes my password to a random string and then sets it back monday morning, but that seems like I'd have to have my password unencrypted somewhere. Alternatively, encrypt my ssh keys?

If you have insights or suggestions, I'd appreciate them.

2
  • A little more information about what you use for login (SSH I assume?) and if you are logging into a specific machine (with a static IP?), would be helpful.
    – Chris
    May 7, 2016 at 2:11
  • Possibly related to unix.stackexchange.com/questions/234590/… (if @mikemtnbikes is using SSH)
    – user533208
    May 7, 2016 at 4:18

2 Answers 2

0

[Option #1]

Assuming you are referring to logging in over SSH into your specific work computer - the best way would be to just shut down your work machine over the weekend.

[Option #2]

Your script could append the host file and reroute your servers address to local host. There is an example application called "SelfControl" that does this, but it's written for MacOS X: https://github.com/SelfControlApp/selfcontrol/

You could probably get an idea of how they did it there.

This is an old unsupported Linux port of it: https://github.com/zengargoyle/selfcontrol

2
  • 1
    This has the additional benefit of substantial power savings over keeping the computer on all weekend. However, if it's a company server rather than a workstation, shutting it down unilaterally might not be the best idea :)
    – user533208
    May 7, 2016 at 4:18
  • yeah, I want to prevent logging onto a Dept mailserver. May 7, 2016 at 16:05
0

If you log in with ssh keys rather then a password, one easy approach would be simply to rename .ssh/authorized_keys on Friday evening and return it on Monday morning. Using cron, of course.

The downside with this if that there is no failsafe (if the job on Monday morning fails to run then you're potentially locked out all week).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.