Quick SSH Tunnel Script

I wrote this script for a friend who needs to get around a work firewall. The script uses Plink to create an SSH tunnel to a server of your choice. I haven’t added any error handling in it, but I like how it integrates FTP in a batch script. For this script to work, you’ll need at least one server with both FTP and SSH enabled. Make sure to lock down both accounts that you use in the script, and you’ll need to make sure that plink.exe is accessible in the root of the FTP account. Below Is the script, with my SSH and FTP username and passwords blanked out:

@ECHO OFF
 
:: Create the temporary script file, echoing the FTP commands to download plink.exe
> script.ftp ECHO USER FTPUsername
>>script.ftp ECHO FTPPassword
>>script.ftp ECHO lcd C:\
>>script.ftp ECHO binary
>>script.ftp ECHO hash
>>script.ftp ECHO get plink.exe
>>script.ftp ECHO bye
 
:ftp_connect
:: Connect to FTP server using the temporary script for unattended FTP
FTP -v -n -s:script.ftp burnsforce.com
:: For the paranoid: overwrite the temporary file before deleting it
TYPE NUL >script.ftp
DEL script.ftp
 
:plink_connect
:: Now that plink.exe is downloaded, we execute it and create the SSH tunnel
cls
ECHO.
ECHO.
ECHO ====================================================================
ECHO Creating SSH Tunnel Now. Once connected, you will simply see
ECHO a blinking cursor, this is normal.  Minimize this window and go
ECHO configure your browser to use a SOCKS proxy with the following:
ECHO.
ECHO host: localhost
ECHO port: 9999
ECHO.
ECHO To end the tunnel press ctrl + C .
ECHO When prompted, enter 'N' and press ENTER.
ECHO.
ECHO ====================================================================
C:\plink.exe -N -D 9999 SSH_Username@burnsforce.com -pw SSHPASSWORD
 
:End
erase C:\plink.exe
  1. No comments yet.

  1. No trackbacks yet.

Unfortunately you don't have Adobe Flash-Player.... Klicken Sie hier fü kostenlosen Adobe Flash-Player.