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

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?

    Gissmo85
    Gissmo85Answer
    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"

    3 replies

    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"

    Thought Leadership. Security Summit. Thursday, November 12th, PGA National Resort, Palm Beach Gardens, FL.
    Thought Leadership. Security Summit. Thursday, October 8th. Disney's Grand Californian Hotel & SPA, Anaheim, CA.
    Security Operations Summit: Modernize SecOps. Operate AI-Native.AMER: November 4 | 9:00 AM PST. India and SAARC: November 5 | 10:00 AM IST. EMEA: November 5 | 10:30 AM CET. APAC: November 5 | 11:00 AM SGT