Skip to main content
Gissmo85
New Member
July 21, 2017
Solved

reboot the Fortigate over ssh

  • July 21, 2017
  • 1 reply
  • 20484 views

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?

    Best answer by Gissmo85

    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"

    1 reply

    ede_pfau
    SuperUser
    SuperUser
    July 21, 2017

    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.

    Gissmo85
    Gissmo85Author
    New Member
    July 21, 2017

    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
    Gissmo85AuthorAnswer
    New Member
    July 26, 2017

    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"