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