13 Replies Latest reply on Sep 16, 2019 3:23 AM by Keyur Patel

    SSH commands for cisco devices

    Fawwaz Banakher
      Share This:

      Dear experts

       

      I have been requested to use control m to run cisco commands via ssh for some cisco network devices hounestly i dont know if control m can be used for this task so if there is a way or a job type that i can use for my task to schedule the requested commands it will be a big help from you.

       

      Please note that we have control v9

       

      Regards

       

      Fawwaz

        • 1. Re: SSH commands for cisco devices
          Kannaa Ch

          Thread moved to Control-M community

          • 2. Re: SSH commands for cisco devices
            Keyur Patel

            Hi, Yes you can

            To achieve this, I am making few assumption about your setup

             

            I believe that,

            • you are using SSH with TACACS+ authentication SSH session with your CISCO device
            • Also you are not using two factor authentication.
            • You are using putty to connect with CISCO device for SSH

             

            Create Windows Batch script with below command to connect via cmd

            Putty.exe -ssh usename@ip -pw <password> -m c:\commands\commnds.txt (This will make remote connection to CISCO device)

            Create command.txt with the required command to submit onto CISCO device with SSH.

             

            Create Control-M OS type job and provide script path and script name to execute batch script

            You will require Control-M agent on to your computer (Same machine, where you run command shell to connect CISCO device. i.e. your PC may be)

             

            Run job on the above Control-M agent, which will connect to CISCO device and submit all required command, which you have provided in the batch via Control-M job.

             

            if you are using two factor authentication then you have to pass key value as variable to Control-M job

             

            Hope this will help..

             

            Thanks

            4 of 4 people found this helpful
            • 3. Re: SSH commands for cisco devices
              Mark Francome

              If you create a Control-M job and set the Task Type to Command then whatever you enter into the command field will be taken as if you were at the command prompt and entering the command yourself.

               

              On Unix you should be able to set the Run As field to be the userid that you want to execute as (if the Agent has been installed as root). On Windows it takes the userid from whatever the Agent runs as.

               

              In the command filed you can enter up to 512 characters (on recent versions) and use Control-M variables within that command (which can expand the used field up to double, i.e. 1024 characters). You can also use conditional processing within the command to control things within the command, e.g. -

               

              mkdir test && echo "Something" > test/file

              1 of 1 people found this helpful
              • 4. Re: SSH commands for cisco devices
                Fawwaz Banakher

                dears

                 

                I am really sorry for the delay on the response, I tried your suggestion and created the command job but the job shows on execution state and didn't finish or execute anything, I tried the same command from the SSH host used it worked fine on CMD I used the show clock command it worked fine in control m it didn't

                 

                regards

                 

                Fawwaz

                • 5. Re: SSH commands for cisco devices
                  Mark Francome

                  Can you check the Control-M Agent where you are running the process from, try the ag_diag_comm utility.

                  • 6. Re: SSH commands for cisco devices
                    Fawwaz Banakher

                    I checked the agent every thing is seems ok is there any specific option i need to check or change?

                    • 7. Re: SSH commands for cisco devices
                      Fawwaz Banakher

                      The issue is now that when i run a batch file manually it run perfectly but when i try to use control m job it is not working and stuck on the execution mode

                      • 8. Re: SSH commands for cisco devices
                        Keyur Patel

                        Hi,

                        are you running Control-M agent as local system or you have defined log on as user, if so please check Control-M job log, which credential it is using while executing job

                        May be due to permission issue, if you can share screen shot or log, this will help us to find out more about the issue

                        Thanks

                        2 of 2 people found this helpful
                        • 9. Re: SSH commands for cisco devices
                          Keyur Patel

                          Hi - Also can you confirm, when you run command on the server via CMD, what return code you are receiving after successful completion ?

                          I would suggest you to create BAT script and create OS type job to execute

                          Thanks

                          1 of 1 people found this helpful
                          • 10. Re: SSH commands for cisco devices
                            Fawwaz Banakher

                            hi Keyur

                             

                            I changed the user to the user that is executing the job I received a message from the agent (job failed to initialize) for rung the command on CMD when I run the command it simply open a putty session run the command and close the session and the putty log shows a successful execution of the ssh command

                             

                            regards

                             

                            Fawwaz

                            • 11. Re: SSH commands for cisco devices
                              Keyur Patel

                              Hi

                               

                              I am not sure which OS you are using but if it is Windows OS then you need to give below local access right to the user which is execution the Control-M job

                              • Log as Batch
                              • Log as service
                              • Ajdust memory quotes
                              • Replace memory token

                               

                              Have you tried to run command via Batch script ?

                              Thanks

                              1 of 1 people found this helpful
                              • 12. Re: SSH commands for cisco devices
                                Fawwaz Banakher

                                dears

                                 

                                I am really sorry for my delay in responding for each one of you but the good thing that I managed to solve my request by using plink the command line of putty and made command line job from a host server that have the ssh port opened to the network device and it worked as expected.

                                 

                                I really want to thank all of you for the tremendous support

                                 

                                regards

                                 

                                Fawwaz

                                1 of 1 people found this helpful
                                • 13. Re: SSH commands for cisco devices
                                  Keyur Patel

                                  Hi,

                                   

                                  Good to know that you managed to solve via OS type job by using Putty Command line, it will good to see if you can provide screen shot for future reference

                                   

                                  Thanks

                                  1 of 1 people found this helpful