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


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 bash /home/admin/

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/
if [ “$OPERSTATE” = “linkdown” ] ; then
Cli -p 15 -c’
bash ssh -i /home/admin/.ssh/id_rsa bash /home/admin/


what could i missing?

Thanks in advance.

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/ 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 bash /home/admin/

Let’s start there and see if that helps.

Post your Answer

You must be logged in to post an answer.