Controllerless Networks

 View Only
last person joined: 2 days ago 

Instant Mode - the controllerless Wi-Fi solution that's easy to set up, is loaded with security and smarts, and won't break your budget
Expand all | Collapse all

SSH to an IAP via script

This thread has been viewed 16 times
  • 1.  SSH to an IAP via script

    Posted Feb 01, 2021 09:44 AM
    Hello,

    I wanted to see if anyone has a working example of a pythion script that can connect to an IAP cluster and execute basic commands.

    ------------------------------
    Thanks,

    SATX71
    ------------------------------


  • 2.  RE: SSH to an IAP via script

    EMPLOYEE
    Posted Feb 02, 2021 04:35 AM
    Not sure what you are trying to achieve, but you may have a look at Airrecorder.

    And not python, but Expect (which has a Python module as well, so you may use it to convert into python), this is a script that logs in over ssh, checks if a client is connected to the AP, and if it is it will disconnect the client, just as an example:
    #!/usr/bin/expect -f
    
    set timeout 20
    set ip [lindex $argv 0]
    
    spawn ssh admin@$ip
    
    expect "password:"
    
    send -- "ThePassword-here\r"
    
    expect "#"
    send -- "show clients | inc b8:27:eb:01:3a:ff\r"
    
    expect {
       "rpi-client" {
          send -- "disconnect-user mac b8:27:eb:01:3a:ff\r"
       }
       "#" {
          send -- "\r"
       }
    }
    
    expect "#"
    send -- "exit"
    ​

    Note that scripting over SSH is not really recommended as the CLI commands or command output may change over time. Sometimes it is just a pragmatic and quick, so from that points valid approach to fix an immediate issue.



    ------------------------------
    Herman Robers
    ------------------------
    If you have urgent issues, always contact your Aruba partner, distributor, or Aruba TAC Support. Check https://www.arubanetworks.com/support-services/contact-support/ for how to contact Aruba TAC. Any opinions expressed here are solely my own and not necessarily that of Hewlett Packard Enterprise or Aruba Networks.
    ------------------------------



  • 3.  RE: SSH to an IAP via script

    EMPLOYEE
    Posted Feb 06, 2021 07:50 AM
    Hi,

    did you look at netmiko?

    https://github.com/ktbyers/netmiko

    It is written in python and can work with many network vendors. I think IAP's are currently not there, but from my point of view, it should still work. 

    BR
    Florian

    ------------------------------
    -------------------------------------------------------------------------------
    Florian Baaske
    -------------------------------------------------------------------------------
    Any opinions expressed here are solely my own and not necessarily that of Hewlett Packard Enterprise or Aruba Networks.
    -------------------------------------------------------------------------------
    Also visit the AirHeads Youtube Channel:
    https://www.youtube.com/channel/UCFJCnuXFGfEbwEzfcgU_ERQ
    -------------------------------------------------------------------------------
    Feel free to visit my personal Blog
    https://www.flomain.de
    ------------------------------



  • 4.  RE: SSH to an IAP via script

    Posted Feb 25, 2021 01:01 PM
    Thanks guys. Sorry for the last response. I was able to get it working using NetMiko. I didn't realize it would work with Aruba equipment. We aren't allowed to have JRE on our systems here so Air Recorder is not an option unfortunately.

    ------------------------------
    Chris Watson
    ------------------------------