plink
Run remote commands via SSH
TLDR
Connect to an address
SYNOPSIS
plink [options] [user@]host [command]
plink [options] -load session_name [command]
PARAMETERS
-ssh
Forces the use of the SSH protocol for the connection.
-telnet
Forces the use of the Telnet protocol.
-rlogin
Forces the use of the Rlogin protocol.
-raw
Forces the use of the raw TCP protocol.
-P port
Specifies the port number to connect to.
-l username
Specifies the username for login.
-pw password
Specifies the password for authentication. Caution: Using this option on the command line is insecure.
-i keyfile
Specifies the private key file for public-key authentication.
-load session_name
Loads a pre-configured PuTTY saved session.
-batch
Disables all interactive prompts, making it suitable for scripting.
-N
Does not start a remote shell or command; useful for port forwarding only.
-v
Enables verbose messages for debugging.
-C
Enables SSH compression.
-L localport:remotehost:remoteport
Sets up local port forwarding (e.g., 2222:localhost:22).
-R remoteport:localhost:localport
Sets up remote port forwarding (e.g., 8080:localhost:80).
DESCRIPTION
plink is a command-line interface to the PuTTY back ends. It is primarily used for automated operations, such as calling SSH from a script, batch file, or cron job. It can connect to SSH, Telnet, Rlogin, or raw TCP ports, making it highly versatile for various network tasks.
While often associated with Windows, plink is also available on Linux and other Unix-like systems, providing a PuTTY-compatible alternative to the standard ssh client. It supports key-based authentication, port forwarding, and can load saved PuTTY sessions, making it easy to manage complex connection configurations. Its ability to execute commands remotely and transfer files (via its pscp and psftp counterparts) makes it a powerful tool for system administrators and developers.
CAVEATS
Using the -pw option exposes your password in plain text, which can be seen by other users on the system via process lists and may be stored in shell history. It is strongly recommended to use public-key authentication with the -i option or agent forwarding for secure, automated logins. plink relies on PuTTY's private key format, so OpenSSH keys might need conversion using puttygen.
SCRIPTING AND AUTOMATION
plink excels in scripting scenarios where unattended execution is crucial. By combining it with the -batch option and key-based authentication, users can automate tasks like remote command execution, file transfers (using pscp and psftp), and tunnel creation without manual interaction. This makes it invaluable for CI/CD pipelines, backup scripts, and system monitoring.
PUTTY SESSION INTEGRATION
One of plink's unique advantages is its ability to load saved PuTTY sessions using the -load option. This allows users to centralize connection configurations within PuTTY's session management, including hostnames, ports, authentication methods, and port forwarding rules, and then reuse them from the command line without re-specifying all options.
HISTORY
plink is a core component of the PuTTY suite, developed by Simon Tatham. It emerged as the command-line equivalent of the PuTTY GUI client, primarily for Windows systems, to enable automation and scripting of secure shell connections. Its development focused on providing a comprehensive, cross-platform SSH client that could integrate seamlessly with PuTTY's configuration files and saved sessions. Over time, its availability extended to Unix-like systems, including Linux, providing a consistent interface for users accustomed to the PuTTY ecosystem, often used in mixed-OS environments or when specific PuTTY features are desired.