Fix comment re dmemdumpl()
[sgt/putty] / doc / plink.but
... / ...
CommitLineData
1\define{versionidplink} \versionid $Id$
2
3\C{plink} Using the command-line connection tool Plink
4
5\i{Plink} (PuTTY Link) is a command-line connection tool similar to
6UNIX \c{ssh}. It is mostly used for automated operations, such as
7making CVS access a repository on a remote server.
8
9Plink is probably not what you want if you want to run an
10interactive session in a console window.
11
12\H{plink-starting} Starting Plink
13
14Plink is a command line application. This means that you cannot just
15double-click on its icon to run it and instead you have to bring up
16a \i{console window}. In Windows 95, 98, and ME, this is called an
17\q{MS-DOS Prompt}, and in Windows NT and 2000 it is called a
18\q{Command Prompt}. It should be available from the Programs section
19of your Start Menu.
20
21In order to use Plink, the file \c{plink.exe} will need either to be
22on your \i{\c{PATH}} or in your current directory. To add the
23directory containing Plink to your \c{PATH} environment variable,
24type into the console window:
25
26\c set PATH=C:\path\to\putty\directory;%PATH%
27
28This will only work for the lifetime of that particular console
29window. To set your \c{PATH} more permanently on Windows NT, use the
30Environment tab of the System Control Panel. On Windows 95, 98, and
31ME, you will need to edit your \c{AUTOEXEC.BAT} to include a \c{set}
32command like the one above.
33
34\H{plink-usage} Using Plink
35
36This section describes the basics of how to use Plink for
37interactive logins and for automated processes.
38
39Once you've got a console window to type into, you can just type
40\c{plink} on its own to bring up a usage message. This tells you the
41version of Plink you're using, and gives you a brief summary of how to
42use Plink:
43
44\c Z:\sysosd>plink
45\c PuTTY Link: command-line connection utility
46\c Release 0.XX
47\c Usage: plink [options] [user@]host [command]
48\c ("host" can also be a PuTTY saved session name)
49\c Options:
50\c -V print version information and exit
51\c -pgpfp print PGP key fingerprints and exit
52\c -v show verbose messages
53\c -load sessname Load settings from saved session
54\c -ssh -telnet -rlogin -raw
55\c force use of a particular protocol
56\c -P port connect to specified port
57\c -l user connect with specified username
58\c -batch disable all interactive prompts
59\c The following options only apply to SSH connections:
60\c -pw passw login with specified password
61\c -D [listen-IP:]listen-port
62\c Dynamic SOCKS-based port forwarding
63\c -L [listen-IP:]listen-port:host:port
64\c Forward local port to remote address
65\c -R [listen-IP:]listen-port:host:port
66\c Forward remote port to local address
67\c -X -x enable / disable X11 forwarding
68\c -A -a enable / disable agent forwarding
69\c -t -T enable / disable pty allocation
70\c -1 -2 force use of particular protocol version
71\c -4 -6 force use of IPv4 or IPv6
72\c -C enable compression
73\c -i key private key file for authentication
74\c -m file read remote command(s) from file
75\c -s remote command is an SSH subsystem (SSH-2 only)
76\c -N don't start a shell/command (SSH-2 only)
77
78Once this works, you are ready to use Plink.
79
80\S{plink-usage-interactive} Using Plink for interactive logins
81
82To make a simple interactive connection to a remote server, just
83type \c{plink} and then the host name:
84
85\c Z:\sysosd>plink login.example.com
86\c
87\c Debian GNU/Linux 2.2 flunky.example.com
88\c flunky login:
89
90You should then be able to log in as normal and run a session. The
91output sent by the server will be written straight to your command
92prompt window, which will most likely not interpret terminal control
93codes in the way the server expects it to. So if you run any
94full-screen applications, for example, you can expect to see strange
95characters appearing in your window. Interactive connections like
96this are not the main point of Plink.
97
98In order to connect with a different protocol, you can give the
99command line options \c{-ssh}, \c{-telnet}, \c{-rlogin} or \c{-raw}.
100To make an SSH connection, for example:
101
102\c Z:\sysosd>plink -ssh login.example.com
103\c login as:
104
105If you have already set up a PuTTY saved session, then instead of
106supplying a host name, you can give the saved session name. This
107allows you to use public-key authentication, specify a user name,
108and use most of the other features of PuTTY:
109
110\c Z:\sysosd>plink my-ssh-session
111\c Sent username "fred"
112\c Authenticating with public key "fred@winbox"
113\c Last login: Thu Dec 6 19:25:33 2001 from :0.0
114\c fred@flunky:~$
115
116\S{plink-usage-batch} Using Plink for automated connections
117
118More typically Plink is used with the SSH protocol, to enable you to
119talk directly to a program running on the server. To do this you
120have to ensure Plink is \e{using} the SSH protocol. You can do this
121in several ways:
122
123\b Use the \c{-ssh} option as described in
124\k{plink-usage-interactive}.
125
126\b Set up a PuTTY saved session that describes the server you are
127connecting to, and that also specifies the protocol as SSH.
128
129\b Set the Windows environment variable \c{PLINK_PROTOCOL} to the
130word \c{ssh}.
131
132Usually Plink is not invoked directly by a user, but run
133automatically by another process. Therefore you typically do not
134want Plink to prompt you for a user name or a password.
135
136Next, you are likely to need to avoid the various interactive
137prompts Plink can produce. You might be prompted to verify the host
138key of the server you're connecting to, to enter a user name, or to
139enter a password.
140
141To avoid being prompted for the server host key when using Plink for
142an automated connection, you should first make a \e{manual}
143connection (using either of PuTTY or Plink) to the same server,
144verify the host key (see \k{gs-hostkey} for more information), and
145select Yes to add the host key to the Registry. After that, Plink
146commands connecting to that server should not give a host key prompt
147unless the host key changes.
148
149To avoid being prompted for a user name, you can:
150
151\b Use the \c{-l} option to specify a user name on the command line.
152For example, \c{plink login.example.com -l fred}.
153
154\b Set up a PuTTY saved session that describes the server you are
155connecting to, and that also specifies the username to log in as
156(see \k{config-username}).
157
158To avoid being prompted for a password, you should almost certainly
159set up public-key authentication. (See \k{pubkey} for a general
160introduction to public-key authentication.) Again, you can do this
161in two ways:
162
163\b Set up a PuTTY saved session that describes the server you are
164connecting to, and that also specifies a private key file (see
165\k{config-ssh-privkey}). For this to work without prompting, your
166private key will need to have no passphrase.
167
168\b Store the private key in Pageant. See \k{pageant} for further
169information.
170
171Once you have done all this, you should be able to run a remote
172command on the SSH server machine and have it execute automatically
173with no prompting:
174
175\c Z:\sysosd>plink login.example.com -l fred echo hello, world
176\c hello, world
177\c
178\c Z:\sysosd>
179
180Or, if you have set up a saved session with all the connection
181details:
182
183\c Z:\sysosd>plink mysession echo hello, world
184\c hello, world
185\c
186\c Z:\sysosd>
187
188Then you can set up other programs to run this Plink command and
189talk to it as if it were a process on the server machine.
190
191\S{plink-options} Plink command line options
192
193Plink accepts all the general command line options supported by the
194PuTTY tools. See \k{using-general-opts} for a description of these
195options.
196
197Plink also supports some of its own options. The following sections
198describe Plink's specific command-line options.
199
200\S2{plink-option-batch} \c{-batch}: disable all interactive prompts
201
202If you use the \c{-batch} option, Plink will never give an
203interactive prompt while establishing the connection. If the
204server's host key is invalid, for example (see \k{gs-hostkey}), then
205the connection will simply be abandoned instead of asking you what
206to do next.
207
208This may help Plink's behaviour when it is used in automated
209scripts: using \c{-batch}, if something goes wrong at connection
210time, the batch job will fail rather than hang.
211
212\S2{plink-option-s} \c{-s}: remote command is SSH subsystem
213
214If you specify the \c{-s} option, Plink passes the specified command
215as the name of an SSH \q{subsystem} rather than an ordinary command
216line.
217
218(This option is only meaningful with the SSH-2 protocol.)
219
220\H{plink-batch} Using Plink in \i{batch files} and \i{scripts}
221
222Once you have set up Plink to be able to log in to a remote server
223without any interactive prompting (see \k{plink-usage-batch}), you
224can use it for lots of scripting and batch purposes. For example, to
225start a backup on a remote machine, you might use a command like:
226
227\c plink root@myserver /etc/backups/do-backup.sh
228
229Or perhaps you want to fetch all system log lines relating to a
230particular web area:
231
232\c plink mysession grep /~fred/ /var/log/httpd/access.log > fredlog
233
234Any non-interactive command you could usefully run on the server
235command line, you can run in a batch file using Plink in this way.
236
237\H{plink-cvs} Using Plink with \i{CVS}
238
239To use Plink with CVS, you need to set the environment variable
240\c{CVS_RSH} to point to Plink:
241
242\c set CVS_RSH=\path\to\plink.exe
243
244You also need to arrange to be able to connect to a remote host
245without any interactive prompts, as described in
246\k{plink-usage-batch}.
247
248You should then be able to run CVS as follows:
249
250\c cvs -d :ext:user@sessionname:/path/to/repository co module
251
252If you specified a username in your saved session, you don't even
253need to specify the \q{user} part of this, and you can just say:
254
255\c cvs -d :ext:sessionname:/path/to/repository co module
256
257\H{plink-wincvs} Using Plink with \i{WinCVS}
258
259Plink can also be used with WinCVS. Firstly, arrange for Plink to be
260able to connect to a remote host non-interactively, as described in
261\k{plink-usage-batch}.
262
263Then, in WinCVS, bring up the \q{Preferences} dialogue box from the
264\e{Admin} menu, and switch to the \q{Ports} tab. Tick the box there
265labelled \q{Check for an alternate \cw{rsh} name} and in the text
266entry field to the right enter the full path to \c{plink.exe}.
267Select \q{OK} on the \q{Preferences} dialogue box.
268
269Next, select \q{Command Line} from the WinCVS \q{Admin} menu, and type
270a CVS command as in \k{plink-cvs}, for example:
271
272\c cvs -d :ext:user@hostname:/path/to/repository co module
273
274or (if you're using a saved session):
275
276\c cvs -d :ext:user@sessionname:/path/to/repository co module
277
278Select the folder you want to check out to with the \q{Change Folder}
279button, and click \q{OK} to check out your module. Once you've got
280modules checked out, WinCVS will happily invoke plink from the GUI for
281CVS operations.
282
283\# \H{plink-whatelse} Using Plink with... ?