我正在使用 VPN 连接,使用 SSL Network Extender(SNX) 连接到远程服务器。来自远程服务器的连接仅限于 12 小时。之后连接被断开,必须重新启动 SNX 服务器。为了克服这些困难,我正在尝试使用 crontab 自动重启 SNX。
- 我已经创建了一个名为
vpn.sh
的 shell 脚本文件。
#!/bin/bash
snx -d
sleep 3
echo 'password' | snx
- 我在主目录中有配置文件调用
.snxrc
server server.com
username username
reauth yes
- 在 crontab (
crontab -e
) 中我有配置
* */12 * * * bash/home/username/vpn.sh >/home/username/cron.log
它每 12 小时运行一次。但是 snx -d
运行成功但到达 echo 'newpass6' | snx
我收到此错误:
初始化终端失败!
有人遇到过这样的问题吗?请帮我。我已经挣扎了一个星期了。提前致谢。
我已点击此链接进行设置 snx
因为没有终端就无法启动snx客户端。所以我将这些命令放入我的脚本中以在 byobu session 中启动 snx。
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"
我是一名优秀的程序员,十分优秀!