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

reboot the Fortigate over ssh

Hello everybody :),

 

I want to connect via ssh to the fortigate and make a reboot. code: sshpass -p 'password' ssh admin@192.168.209.155 exec reboot The fortigate expects y or n, how do I get the fortigate said y or n?

1 Solution
Gissmo85
New Contributor II

hiermit läuft es:

 

set host 192.168.209.155 set user admin set passw password # # spawn ssh -p 22 -o ConnectionAttempts=3 -o ConnectTimeout=60 -o StrictHostKeyChecking=no $user\@$host # # expect "assword:" send "$passw\n" expect "SOC" # #send " config global\n" #expect "(global)" # send "execute reboot\n" expect "(y/n)" # send "y\n"

View solution in original post

3 REPLIES 3
ede_pfau
SuperUser
SuperUser

maybe like so?

echo y | sshpass -p 'password' ssh admin@192.168.209.155 exec reboot

That depends on how sshpass treats stdin. I would give it a try.


Ede


"Kernel panic: Aiee, killing interrupt handler!"
Ede"Kernel panic: Aiee, killing interrupt handler!"
Gissmo85
New Contributor II

Hi Ede,

 

looks not good.

the 'y' is not sending to the Fortinet.

 

At the moment I try it now with the expect command.

 

code:

 

spawn sshpass -p "password" ssh admin@192.168.209.155 exec reboot expect "Do you want to continue? (y/n)" {send_user "y\r"} expect eof ----------------------

but this are also not working.

 

Gissmo85
New Contributor II

hiermit läuft es:

 

set host 192.168.209.155 set user admin set passw password # # spawn ssh -p 22 -o ConnectionAttempts=3 -o ConnectTimeout=60 -o StrictHostKeyChecking=no $user\@$host # # expect "assword:" send "$passw\n" expect "SOC" # #send " config global\n" #expect "(global)" # send "execute reboot\n" expect "(y/n)" # send "y\n"

Labels
Top Kudoed Authors