Posted on September 22, 2018 6:32 pm
 |  Asked by Sinan
 |  1570 views
0
0
Print Friendly, PDF & Email

Hi,

I am trying to SSH from one arista to another then execute a file.

if i run below commmand manually on first arista cli it’s connected second switch and execute file correctly.

SW01#bash ssh -i /home/admin/.ssh/id_rsa 1.1.1.2 bash /home/admin/eth1_up.sh

but when i want to automate and write an event-handler on first arista it’s connected second switch but not execute file.
!
event-handler test
trigger on-intf Ethernet1 operstatus
action bash /home/admin/test.sh
!

test.sh
if [ “$OPERSTATE” = “linkdown” ] ; then
Cli -p 15 -c’
bash ssh -i /home/admin/.ssh/id_rsa 172.25.85.101 bash /home/admin/eth1_up.sh

fi

what could i missing?

Thanks in advance.

0
Posted by Adam Levin
Answered on September 22, 2018 7:06 pm

Hi Sinan!

There are a few things to check on here. First, is your /home/admin/test.sh script executable? It should be mode 755 at least. Second, does the SSH connection require a passphrase for the id_rsa key? (Note that if it doesn’t, you might not want to use the admin account for this, as it’s a security risk.)

Third, it looks like you have several layers of OS calls that could be confusing things. When you set up an event-handler, the event-handler action runs in the CLI. You’re calling bash to run the script, which is fine, but then in your script you call CLI, which calls bash again.

The “then” section of your script could be simplified as:
ssh -i /home/admin/.ssh/id_rsa 172.25.85.101 bash /home/admin/eth1_up.sh

Let’s start there and see if that helps.

Post your Answer

You must be logged in to post an answer.