![]() Therefore you should consider to set ssh -o "ServerAliveInterval 60" -o "ServerAliveCountMax 120" 2 hours of trying to keep the connection alive, you can do: The default value of ServerAliveCountMax is 3 (see manpage ssh_config).Įxample: If you set ServerAliveInterval to 60 and leave ServerAliveCountMax as it is, this means the keepalive will only wait for 3 * 60 = 180 seconds = 3 minutes before quiting. This will be done ServerAliveCountMax times if no response is received.The ServerAliveInterval will send a keepalive every x seconds (default is 0, which disables this feature if not set to something else).If exist nmap_temp2.txt (del nmap_temp2.In addition to Mike Pennington's answer, I would like to make you aware of ServerAliveCountMax too. If exist nmap_temp.txt (del nmap_temp.txt) Rem Run through all IPs to cache the SSH Host Key if not already cachedįor /F "tokens=*" %%A in (%IPFILE%) do ( echo y | "C:\Program Files\PuTTY\pscp.exe" -l root -i "C:\Program Files\PuTTY\SSH.ppk" -touch %%A:/tmp/test )įor /F "tokens=1" %%A in (%IPFILE%) do ( "C:\Program Files\PuTTY\putty.exe" -ssh %%A -t -l root -i "C:\Program Files\PuTTY\SSH.ppk" -m "C:\Program Files\PuTTY\scripts\%SCRIPT%" ) Set /p KEYCACHE=Scan and cache SSH key (y/n) ? Type "nmap_temp2.txt" | repl " " "" > %IPFILE% Rem remove hidden space at end of IP (requires "repl" be in the batch file directory) Rem 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:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |