G+_Ray Lorenz Posted October 18, 2017 Share Posted October 18, 2017 Hello, Everyone. I am new to coding and I really have no experience. I was giving a task to find a script to ssh to 100 devices which basically ask for username and password and then run two commands. There is a lot of stuff on the internet. What is best way accomplish this using perl, from a file with 100 IP addresses. Security is not an issue, putting the username and password in clear text is fine in the script. It is a one time run and not left on the machine. Thanks for any help Link to comment Share on other sites More sharing options...
G+_Travis Hershberger Posted October 18, 2017 Share Posted October 18, 2017 I assume this is a homework assignment? Nobody would run scripts this way in the real world. At worst you'd use SSH key based authentication, at best ansible or saltstack that are automation told meant four doing this sorry of work. If you absolutely must do it the way you described, then I'd put the username and password in a csv file, and use Pearl to iterate through each line on the file. Link to comment Share on other sites More sharing options...
G+_Travis Hershberger Posted October 18, 2017 Share Posted October 18, 2017 ssh key based authentication is easy to setup with ssh-copy-id. 'ssh-copy-id user@host' for each of the 100 computers. Then all you need to do is creat a script with 'ssh user@host command to run' for each command on each host .. there are shells available that make it easy to do this on many systems at the same time. Link to comment Share on other sites More sharing options...
Recommended Posts