General:
Resources:
PuTTY Private Key via ENV Variable:
set identity="x:\base\docs\keys\generic.ppk"
Set this ENV variable via System Properties, Environment Variables, User.
--------------------------------------------------------------------------------
To use private/public keys with PuTTY, you must import the key with puttygen.exe
and then export the key in the PuTTY format.
Standard PuTTY Stores Session Data in the Registry:
HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions\{sessionname}
--------------------------------------------------------------------------------
PPK PuTTY Private Key File:
Do not manually edit any parts of the private key file. This ASCII text file
has a "MAC" signature at the end which will be invalid if edited using a text
editor (eg don't modify the "comment" field manually). You can open the file,
modify the contents thru puttygen.exe and then save the contents which will
regenerate a new MAC signature.
You can also open the private key and add or remove a passphrase and then save
the private PPK file. Using a passphrase will encrypt the private key to ensure
that it can only be used for authentication by the valid owner. If you do not
use a passphrase, you can configure the key as "restricted" on the server side,
read the SSH documentation on how to do this.
--------------------------------------------------------------------------------
putty.exe [-ssh | -telnet | -rlogin | -raw] [user@]host
putty.exe user@rhost
putty.exe -ssh user@rhost
putty.exe -load "session name"
putty.exe -cleanup # remove reg and seed
putty.exe -m commands.txt user@rhost # run commands on rhost
pscp.exe -scp user@rhost:/path/to/file . # get file
pscp.exe -scp -r user@rhost:/path/to/dir . # get dir
pscp.exe -scp -ls user@rhost:. # list home folder
pscp.exe -scp -r dir user@rhost:/tmp # put dir
pscp.exe -scp -ls -i .\id_dsa.ppk user@rhost:. # user priv key
plink root@rhost /base/backup.sh # run remote command
plink mysessionx grep /~xyz/ /x/access.log >xyz.log # save search
plink.exe -m commands.txt user@rhost # run commands on rhost
Environment Variables:
PLINK_PROTOCOL=ssh
PuTTY
The -A option turns on SSH agent forwarding, and -a turns it off.
The -C option enables compression of the data sent across the network.
The -1 and -2 options force PuTTY to use version 1 or 2 of the SSH protocol.
The -s option specifies remote command is an SSH subsystem (SSH-2 only)
--------------------------------------------------------------------------------
PuTTY Port Forwarding / SSH Tunneling (-L, -R, -D)
To forward a local port (say 5110) to a remote destination (x.com port 110):
putty -L 5110:x.com:110 -load mysession
plink mysession -L 5110:x.com:110
To forward a remote port to a local destination, just use the -R option
instead of -L:
putty -R 5023:myhouse.org:23 -load mysession
plink mysession -R 5023:myhouse.org:23
To specify an IP address for the listening end of the tunnel, prepend it to
the argument:
plink -L 127.0.0.5:23:localhost:23 myhost
To set up SOCKS-based dynamic port forwarding on a local port, use the -D
option. For this one you only have to pass the port number:
putty -D 4096 -load mysession
The SSH protocol does not support forwarding the UDP protocol. Using remote
port fowarding, most servers will not allow you to listen on port numbers less
than 1024.
The -N option prevents PuTTY from attempting to start a shell or command on the
remote server. You might want to use this option if you are only using the SSH
connection for port forwarding, and your user account on the server does not
have the ability to run a shell. This feature is only available in SSH protocol
version 2.
--------------------------------------------------------------------------------
Remote Connection, No SHell
-nc: make a remote network connection in place of a remote shell or command
The -nc option prevents Plink (or PuTTY) from attempting to start a shell or
command on the remote server. Instead, it will instruct the remote server to
open a network connection to a host name and port number specified by you, and
treat that network connection as if it were the main session.
You specify a host and port as an argument to the -nc option, with a colon
separating the host name from the port number, like this:
plink host1.example.com -nc host2.example.com:1234
You might want to use this feature if you needed to make an SSH connection to
a target host which you can only reach by going through a proxy host, and rather
than using port forwarding you prefer to use the local proxy feature. In this
situation you might select ‘Local’ proxy type, set your local proxy command to
be ‘plink %proxyhost -nc %host:%port’, enter the target host name on the Session
panel, and enter the directly reachable proxy host name on the Proxy panel.
This feature is only available in SSH protocol version 2. It is not available
in the file transfer tools PSCP and PSFTP. It is available in PuTTY itself,
although it is unlikely to be very useful in any tool other than Plink. Also,
-nc uses the same server functionality as port forwarding, so it will not work
if your server administrator has disabled port forwarding.
(The option is named -nc after the Unix program nc, short for ‘netcat’. The
command ‘plink host1 -nc host2:port’ is very similar in functionality to
'plink host1 nc host2 port', which invokes nc on the server and tells it to
connect to the specified destination. However, Plink's built-in -nc option does
not depend on the nc program being installed on the server.)
--------------------------------------------------------------------------------
PuTTY File (putty.conf)
sessions=.\cache\sessions
sshhostkeys=.\cache\hostkeys
seedfile=.\putty.rnd
sessionsuffix=.session
keysuffix=.hostkey
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------