Plink

Plink (PuTTY Link) is a command-line connection tool similar to UNIX ssh. It is mostly used for automated operations, such as making CVS access a repository on a remote server. Citation.

INSTALLATION
1. Under Your windows machine using DOS prompt create a directory name as systools

cd\
mkdir systools
cd systools

2. You need to download PLINK and put it under c:\systools
You can download it by this URL

Starting Plink
In order to use Plink, the file plink.exe will need either to be on your PATH or in your current directory. To add the directory containing Plink to your PATH environment variable, type into the console window:

set PATH=C:\path\to\plink\directory;%PATH%

or

set PATH=C:\systools

This will only work for the lifetime of that particular console window.

Using Plink
This section describes the basics of how to use Plink for interactive logins and for automated processes.
Once you’ve got a console window to type into, you can just type plink on its own to bring up a usage message. This tells you the version of Plink you’re using, and gives you a brief summary of how to use Plink:

C:\systools>plink

PuTTY Link: command-line connection utility
Release 0.60
Usage: plink [options] [user@]host [command]
       ("host" can also be a PuTTY saved session name)
Options:
  -V        print version information and exit
  -pgpfp    print PGP key fingerprints and exit
  -v        show verbose messages
  -load sessname  Load settings from saved session
  -ssh -telnet -rlogin -raw
            force use of a particular protocol
  -P port   connect to specified port
  -l user   connect with specified username
  -batch    disable all interactive prompts
 
The following options only apply to SSH connections:
  -pw passw login with specified password
  -D [listen-IP:]listen-port
            Dynamic SOCKS-based port forwarding
  -L [listen-IP:]listen-port:host:port
            Forward local port to remote address
  -R [listen-IP:]listen-port:host:port
            Forward remote port to local address
  -X -x     enable / disable X11 forwarding
  -A -a     enable / disable agent forwarding
  -t -T     enable / disable pty allocation
  -1 -2     force use of particular protocol version
  -4 -6     force use of IPv4 or IPv6
  -C        enable compression
  -i key    private key file for authentication
  -noagent  disable use of Pageant
  -agent    enable use of Pageant
  -m file   read remote command(s) from file
  -s        remote command is an SSH subsystem (SSH-2 only)
  -N        don't start a shell/command (SSH-2 only)
  -nc host:port
            open tunnel in place of session (SSH-2 only)

Using Plink for Interactive Logins
To make a simple interactive connection to a remote server, just type plink and then the host name:

C:\systools\plink server1.sample.com

Debian GNU/Linux 2.2 server1.sample.com
server1 login:

OR might give you:

The server's host key is not cached in the registry. You
have no guarantee that the server is the computer you
think it is.
The server's rsa2 key fingerprint is:
ssh-rsa 1024 b5:ec:c6:12:08:64:69:bc:f8:3b:36:18:d9:15:e1:e9
If you trust this host, enter "y" to add the key to
PuTTY's cache and carry on connecting.
If you want to carry on connecting just once, without
adding the key to the cache, enter "n".
If you do not trust this host, press Return to abandon the
connection.
Store key in cache? (y/n)  y
login as: root
Using keyboard-interactive authentication.
password:  XXXXXX
Last login: Tue Oct  30 18:14:48 2012 from xxx.xxx.xxx.xxx
server1:~#

Using Plink for Automated Connections
More typically Plink is used with the SSH protocol, to enable you to talk directly to a program running on the server.
To do this you have to ensure Plink is using the SSH protocol. You can do this in several ways:

Use the -ssh option.
Set up a PuTTY saved session that describes the server you are connecting to, and that also specifies the protocol as SSH.
Set the Windows environment variable PLINK_PROTOCOL to the word ssh.
For testing:

>plink -ssh -pw somepassword root@server1.sample.com

Now we should create a text file for linux command.
Lets say we created the apacherestart.txt and with this details:

# 
# This script will restart apache
#
/etc/init.d/apache2 restart