Note about separate client-server and server-client encryption in SSH-2
[sgt/putty] / doc / plink.but
CommitLineData
e117a742 1\versionid $Id: plink.but,v 1.16 2002/08/07 19:20:06 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
46\c Release 0.50
47\c Usage: plink [options] [user@]host [command]
48\c Options:
49\c -v show verbose messages
50\c -ssh force use of ssh protocol
51\c -P port connect to specified port
52\c -pw passw login with specified password
53
2f8d6d43 54Once this works, you are ready to use Plink.
55
56\S{plink-usage-interactive} Using Plink for interactive logins
57
58To make a simple interactive connection to a remote server, just
59type \c{plink} and then the host name:
60
61\c Z:\sysosd>plink login.example.com
62\c
63\c Debian GNU/Linux 2.2 flunky.example.com
64\c flunky login:
65
66You should then be able to log in as normal and run a session. The
67output sent by the server will be written straight to your command
68prompt window, which will most likely not interpret terminal control
69codes in the way the server expects it to. So if you run any
70full-screen applications, for example, you can expect to see strange
71characters appearing in your window. Interactive connections like
72this are not the main point of Plink.
73
74In order to connect with a different protocol, you can give the
75command line options \c{-ssh}, \c{-telnet}, \c{-rlogin} or \c{-raw}.
76To make an SSH connection, for example:
77
78\c Z:\sysosd>plink -ssh login.example.com
79\c login as:
80
81If you have already set up a PuTTY saved session, then instead of
82supplying a host name, you can give the saved session name. This
83allows you to use public-key authentication, specify a user name,
84and use most of the other features of PuTTY:
85
86\c Z:\sysosd>plink my-ssh-session
87\c Sent username "fred"
88\c Authenticating with public key "fred@winbox"
89\c Last login: Thu Dec 6 19:25:33 2001 from :0.0
90\c fred@flunky:~$
91
92\S{plink-usage-batch} Using Plink for automated connections
93
94More typically Plink is used with the SSH protocol, to enable you to
95talk directly to a program running on the server. To do this you
96have to ensure Plink is \e{using} the SSH protocol. You can do this
97in several ways:
98
99\b Use the \c{-ssh} option as described in
100\k{plink-usage-interactive}.
101
102\b Set up a PuTTY saved session that describes the server you are
103connecting to, and that also specifies the protocol as SSH.
104
105\b Set the Windows environment variable \c{PLINK_PROTOCOL} to the
106word \c{ssh}.
107
108Usually Plink is not invoked directly by a user, but run
109automatically by another process. Therefore you typically do not
110want Plink to prompt you for a user name or a password.
111
112To avoid being prompted for a user name, you can:
113
114\b Use the \c{-l} option to specify a user name on the command line.
115For example, \c{plink login.example.com -l fred}.
116
117\b Set up a PuTTY saved session that describes the server you are
118connecting to, and that also specifies the username to log in as
119(see \k{config-username}).
120
121To avoid being prompted for a password, you should almost certainly
122set up public-key authentication. (See \k{pubkey} for a general
123introduction to public-key authentication.) Again, you can do this
124in two ways:
125
126\b Set up a PuTTY saved session that describes the server you are
127connecting to, and that also specifies a private key file (see
128\k{config-ssh-privkey}). For this to work without prompting, your
129private key will need to have no passphrase.
130
131\b Store the private key in Pageant. See \k{pageant} for further
132information.
133
134Once you have done all this, you should be able to run a remote
135command on the SSH server machine and have it execute automatically
136with no prompting:
137
138\c Z:\sysosd>plink login.example.com -l fred echo hello, world
139\c hello, world
140\c
141\c Z:\sysosd>
142
143Or, if you have set up a saved session with all the connection
144details:
145
146\c Z:\sysosd>plink mysession echo hello, world
147\c hello, world
148\c
149\c Z:\sysosd>
150
151Then you can set up other programs to run this Plink command and
152talk to it as if it were a process on the server machine.
bace5431 153
e117a742 154\S{plink-options} Plink command line options
ff2ae367 155
e117a742 156Plink accepts all the general command line options supported by the
157PuTTY tools. See \k{using-general-opts} for a description of these
158options.
bace5431 159
e117a742 160In addition to this, Plink accepts one other option: the \c{-batch}
161option. If you use the \c{-batch} option, Plink will never give an
ff2ae367 162interactive prompt while establishing the connection. If the
163server's host key is invalid, for example (see \k{gs-hostkey}), then
164the connection will simply be abandoned instead of asking you what
165to do next.
166
167This may help Plink's behaviour when it is used in automated
168scripts: using \c{-batch}, if something goes wrong at connection
169time, the batch job will fail rather than hang.
170
eaebbdf8 171\H{plink-batch} Using Plink in \i{batch files} and \i{scripts}
bace5431 172
2f8d6d43 173Once you have set up Plink to be able to log in to a remote server
174without any interactive prompting (see \k{plink-usage-batch}), you
175can use it for lots of scripting and batch purposes. For example, to
176start a backup on a remote machine, you might use a command like:
177
178\c plink root@myserver /etc/backups/do-backup.sh
179
180Or perhaps you want to fetch all system log lines relating to a
181particular web area:
182
183\c plink mysession grep /~fjbloggs/ /var/log/httpd/access.log > fredlogs
184
185Any non-interactive command you could usefully run on the server
186command line, you can run in a batch file using Plink in this way.
187
eaebbdf8 188\H{plink-cvs} Using Plink with \i{CVS}
189
7638530e 190To use Plink with CVS, you need to set the environment variable
191\c{CVS_RSH} to point to Plink:
eaebbdf8 192
193\c set CVS_RSH=\path\to\plink.exe
7638530e 194
195You also need to arrange to be able to connect to a remote host
2f8d6d43 196without any interactive prompts, as described in
197\k{plink-usage-batch}.
7638530e 198
2f8d6d43 199You should then be able to run CVS as follows:
7638530e 200
201\c cvs -d :ext:user@sessionname:/path/to/repository co module
202
2f8d6d43 203If you specified a username in your saved session, you don't even
204need to specify the \q{user} part of this, and you can just say:
7638530e 205
206\c cvs -d :ext:sessionname:/path/to/repository co module
207
7638530e 208\H{plink-wincvs} Using Plink with \i{WinCVS}
209
210Plink can also be used with WinCVS. Firstly, arrange for Plink to be
2f8d6d43 211able to connect to a remote host non-interactively, as described in
212\k{plink-usage-batch}.
eaebbdf8 213
2f8d6d43 214Then, in WinCVS, bring up the \q{Preferences} dialogue box from the
d60c975d 215\e{Admin} menu, and switch to the \q{Ports} tab. Tick the box there
2f8d6d43 216labelled \q{Check for an alternate \cw{rsh} name} and in the text
217entry field to the right enter the full path to \c{plink.exe}.
218Select \q{OK} on the \q{Preferences} dialogue box.
eaebbdf8 219
d60c975d 220Next, select \q{Command Line} from the WinCVS \q{Admin} menu, and type
7638530e 221a CVS command as in \k{plink-cvs}, for example:
222
223\c cvs -d :ext:user@hostname:/path/to/repository co module
eaebbdf8 224
a88d77d6 225or (if you're using a saved session):
226
227\c cvs -d :ext:user@sessionname:/path/to/repository co module
228
d60c975d 229Select the folder you want to check out to with the \q{Change Folder}
230button, and click \q{OK} to check out your module. Once you've got
7638530e 231modules checked out, WinCVS will happily invoke plink from the GUI for
232CVS operations.
bace5431 233
2f8d6d43 234\# \H{plink-whatelse} Using Plink with... ?