Repo URL:
https://github.com/jamesrwhite/minicron
The idea here is that one server holds the "hub", aka the Minicron server. The other servers are simply clients. We use ssh tunneling from clients to communicate with the server. The server should be able to ssh into the client machines, in order to modify the client's crontab. We add public keys with a prefix that only allow root ssh access from a single IP (the server's IP).
-
SSH server configuration
cat > /etc/ssh/sshd_config Port 4242 Protocol 2 PermitRootLogin without-password PasswordAuthentication no
rc-service sshd restart
-
Linode static networking
https://www.linode.com/docs/networking/linux-static-ip-configuration
The clients must be able to connect to the server. One way to do this is via ssh tunnels.
Acquire the 42.minicron
private key. Create a /root/.ssh/config
file:
Host 42-core-tunnel
HostName 192.168.132.240
User root
Port 4242
IdentityFile ~/.ssh/42.minicron.key
LocalForward 9000 127.0.0.1:9000
To start the tunnel, run this:
ssh -f -N 42-core-tunnel
Generate an ssh keypair for the root user:
ssh-keygen -b 4096
emerge --sync
emerge -av ruby
gem install minicron
Install minicron.toml
config file. See example below.
cat > /etc/minicron.toml
emerge -av mysql
gem install mysql2
mysql
minicron db setup
Start server:
minicron server start
Since we're allowing the server to perform operations as root on a client machine, we want to be somewhat secure.
When creating a host in minicron, take the public key and append it to that host's /root/.ssh/authorized_keys
.
However, add the prefix from="<server ip>" <public key>
.