Support Forum
The Forums are a place to find answers on a range of Fortinet products from peers and product experts.
jbiancoCA
New Contributor

Connect to vpn - FortiCLient using Linux command line, passing password

Hi there,

 

On a Debian/Ubuntu box, I have installed: forticlient_vpn_7.0.7.0246_amd64.deb, which using the command line "not Desktop" just bash.

 

I am able to connect to the company VPN using a syntax like:

 

/opt/forticlient/vpn -s office.***.com:_PORT_GOES_HERE_ -u MY_USERNAME -p
password:
State: Connecting
...

 

I was wondering how I can pass the password when the VPN app asks for, or if there is other parameter?

 

Thanks in advance.

4 REPLIES 4
gfleming
Staff
Staff

Are you wanting to pass the password in the command line arguments to avoid having it be interactive?

Cheers,
Graham
jbiancoCA
New Contributor

yes, I'd like that.

gfleming
Staff
Staff

DO any of these CLI options help you? Looks like you can create a profile that you reference in the CLI arguments...

 

https://docs.fortinet.com/document/forticlient/7.0.7/administration-guide/41299/forticlient-linux-cl...

Cheers,
Graham
jbiancoCA
New Contributor

I am not sure about what you are mentioning, I am not familiar with that one.

 

I'd like to be able to pass to the "FortiClient" VPN binary, like other VPN software I have worked with "using CLI" where I can pass the password, the same way I pass username and other parameters.

 

I am able to use 'expect' this way, but it's hacky

 

expect expect_response.exp 'passwordGoesHere'

 

Running on Ubuntu 20.04 LTS, but I assume for Debian 10/11 should work as well.

 

content of file: expect_response.exp it expects one parameter:

 

#!/usr/bin/expect

set PASS [lindex $argv 0]
set timeout -1
spawn /opt/forticlient/vpn -s officeAddressAndPortGoesHere -u myUserNameGoesHere -p
expect -exact "password:"
send -- "$PASS\r"
set timeout -1
expect eof

 

Labels
Top Kudoed Authors