4/10/2024 0 Comments Ssh multiple sessions puttyRem nmap formatting is not correct, the following removes extra infoįor /f "tokens=2" %%A in (nmap_temp.txt) do echo %%A > nmap_temp2.txt Nmap -open -n -p22 %RANGE% -oG - | findstr /E Up > nmap_temp.txt Nmap -open -n -p22 -iL %IPFILE% -oG - | findstr /E Up > nmap_temp.txt Rem Check whether IP type is "range" as nmap cannot read an IP range from file and must be type directly in nmap command Set /p SCAN=Do Nmap scan first? (recommended): Rem You must modify the CACHEKEY and SCRIPT section to reflect your SSH key locationĮCHO (Working directory is set to C:\Program Files\PuTTY\scripts\)ĮCHO Enter the IP range(s) as in the following example. This is mostly useful for having a single script (such as updating an SSL certificate) across a range of machines. The nmap and PuTTY working directories are in your command path.Batch scripts and IPlist files are installed in C:\Program Files\PuTTY\scripts\.You have the full PuTTY package and SSH key are installed in C:\Program Files\PuTTY\.Optionally run pscp command to autocache the host key (PuTTY does not do this automatically).want to avoid IPs putty cannot connect to, avoiding script being able to continue properly.Optionally do nmap scan for port 22 open (i.e.Script name to run on the IP/range (actual Unix sh/ ksh type script).Here is the script I made to hopefully save some people hours of syntax and man page research. Correspondingly, if you log into one machine as a proxy to hop into another one, that middle machine will need both. You should only need the server running on machines you log in to and only need the client on machines you log in from. Once setup completes, return to Apps and Optional Features and confirm OpenSSH is listed.Īfter this, you should be able to use ssh like you would on a Unix-like system: C:\WINDOWS\system32>ssh "ls -l ~".Find OpenSSH Client, then select Install.If not, at the top of the page, select Add a feature, then: Scan the list to see if the OpenSSH is already installed.Open Settings, select Apps, then select Optional Features.You can install OpenSSH with Windows Features as below or download the portable version from GitHub. (note: I wasn't able to get clusterssh running on windows cygwin as of july 2014 so i couldn't really speak to how good/bad the program is at accomplishing what OP asked for.) HOSTS=.If you're using Windows 10 or higher, you might be interested to know that Microsoft has a beta of OpenSSH, both the client and the server. sshpass doesnt work until you have manually acknowledged adding the ssh key for the remote servers. One thing to note, you'll have to login using ssh from the command line of your admin machine for each server you want to manage. You will have to install sshpass (i know people really hate this package but i was too lazy to get ssh keys going on all the servers) separately which can be downloaded from sourceforge. You'll need cygwin on windows (which is the only place i've tested this). Save this code into a file named copyFileToServers.sh, create a serverlist file that has a list of ips or server names and execute by typeing. I've found it easier than both clusterssh and mtputty. I'm a bash scripting novice so likely not the most efficient or best option but seems to be pretty easy to manage. In addition to using clusterssh or mtputty, a simpile bash script can login to a list of remote servers using ssh, copy a file to each using scp and execute a script on each of the servers. this is my first post here so I cant upload images. You will need to create a folder named temp inside putty main folder and you might need to customize putty logging to save a file per ip or pear session. Putty -ssh -pw paaswd -m commands.txt 192.168.0.22 user_name paaswd Putty -ssh -pw paaswd -m commands.txt 192.168.0.21 user_name paaswd If you want to run the exact command list on every machine then you save it to a file and use another sheet to generate the command-line batch. cmd Command ip user name password Command templateĮcho /snmp set enabled=yes >temp\10.10.0.9.txt| putty -ssh -pw passwd -m temp\10.10.0.9.txt 10.10.0.9 user_name passwd /snmp set enabled=yesĮcho /snmp set enabled=yes >temp\10.10.0.31.txt| putty -ssh -pw passwd2 -m temp\10.10.0.31.txt 10.10.0.31 user_name2 passwd2 /snmp set enabled=yes it works like magic even if you have to customize the command for each server. I used an excel sheet to build cmd commands including putty ssh log-in then copy past the columns in a cmd window. I have recently figure out a way to do this easily.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |