3

I am using SoftEther VPN client to connect to a remote machine. In order to ssh into the remote machine, I first have to take the following steps:

cd ~/vpnclient
sudo ./vpnclient start
./vpncmd
2 (asked to pick an option)
Enter "" (with no input)
accountconnect
<my_name_1>
exit
sudo dhclient <my_name_2>

After that, I am able to ssh. But I have to do that each time I restart.

I'm sure there must be a way that I can automate all this but I'm not sure where to start. Could I write a shell script to do this, even though it runs a program and then types things within the program? Or should I be doing this with Python?

Any help would be great.

3 Answers3

5

If you are running Linux as root, you should be able to add a command like

cd /home/username/vpnclient
./vpnclient start

to /etc/rc.local (before the "exit 1" statement if it exists). Theoretically you should only need to run vpncmd once to set up your account, and it should then save that config in vpn_client config.

That said, if you do need to enter this vpncmd, you can do it with bash, for example by adding the following lines to a bash script (or to rc.local) -

(
echo "2"
echo ""
echo "accountconnect"
echo <my_name_1>
echo "exit" ) | ./vpncmd

dhclient <my_name_2>

(Sudo is not needed because you are root).

davidgo
  • 73,366
0

Command: ./vpncmd vpnclient> AccountStartupSet

It will connect your account even after rebooting the system. And you can automate your dhclient by using /etc/network/interfaces file

0

Google give me this form when I face the same request. Then I find out a best way: #vpncmd 2 (asked to pick an option) Enter "" (with no input) AccountStartupSet <you_name> exit

Next time just run : vpnclient start