I am using VPN connection using SSL Network Extender(SNX) to connect to remote server. The connection from the remote server is limited to only 12 hours. After that the connection is being disconnected and have to restart the SNX server again. To overcome those hardship I am trying to automate SNX restart using crontab.
vpn.sh
.#!/bin/bash snx -d sleep 3 echo 'password' | snx
.snxrc
inside home directoryserver server.com username username reauth yes
crontab -e
) config I have* */12 * * * bash /home/username/vpn.sh > /home/username/cron.log
It runs every 12 hours. But snx -d
runs successfully but on reaching echo 'newpass6' | snx
I am getting this error:
Failed to init terminal!
Any body encountered such issues? Please help me. I have been struggling for a week now. Thanks in advance.
I have followed this link to setup snx
Because snx client cannot start without a terminal. So i put in my script these commands to start snx in a byobu session.
byobu new-session -d -s vpn;
byobu new-window -t vpn:1 -n "snx" "echo your_password | snx -s your_ip -u your_user; sleep 10"