Search code examples
linuxbashshellf5

F5 load balancer interaction


I want to run a bash script from my linux machine. It should connect to F5 Load balancer and run set of commands on the load balancer.

Working command used to connect F5:

sshpass -p "password" ssh username@f5hostname  

Bash script i tried:

#!/bin/bash

sshpass -p "password" ssh username@f5hostname

modify /ltm pool  poolA_8080 members modify { 10.32.76.21:8080 { session user-
disabled state user-down } }

If I run this script from my linux machine, it logs in to F5 but the 'modify' command is not getting executed.


Solution

  • If I understand this right, there is a new line character after ssh. Try following:

    #!/bin/bash
    
    sshpass -p "password" ssh username@f5hostname \
    "modify /ltm pool poolA_8080 members modify { 10.32.76.21:8080 { session user-disabled state user-down } }"
    

    On a side note, storing passwords in scripts is not a good idea as they can easily leak. Better use a key-based ssh login.