plink对于自动化的执行命令和工作非常有好处。plink可以让我们直接在命令行制定好命令,然后执行,完成后自动关闭session。
Plink: command-line connection utility
Release 0.81
Usage: plink [options] [user@]host [command]("host" can also be a PuTTY saved session name)
Options:-V        print version information and exit-pgpfp    print PGP key fingerprints and exit-v        show verbose messages-load sessname  Load settings from saved session-ssh -telnet -rlogin -raw -serialforce use of a particular protocol-ssh-connectionforce use of the bare ssh-connection protocol-P port   connect to specified port-l user   connect with specified username-batch    disable all interactive prompts-proxycmd commanduse 'command' as local proxy-sercfg configuration-string (e.g. 19200,8,n,1,X)Specify the serial configuration (serial only)
The following options only apply to SSH connections:-pwfile file   login with password read from specified file-D [listen-IP:]listen-portDynamic SOCKS-based port forwarding-L [listen-IP:]listen-port:host:portForward local port to remote address-R [listen-IP:]listen-port:host:portForward remote port to local address-X -x     enable / disable X11 forwarding-A -a     enable / disable agent forwarding-t -T     enable / disable pty allocation-1 -2     force use of particular SSH protocol version-4 -6     force use of IPv4 or IPv6-C        enable compression-i key    private key file for user authentication-noagent  disable use of Pageant-agent    enable use of Pageant-no-trivial-authdisconnect if SSH authentication succeeds trivially-noshare  disable use of connection sharing-share    enable use of connection sharing-hostkey keyidmanually specify a host key (may be repeated)-sanitise-stderr, -sanitise-stdout, -no-sanitise-stderr, -no-sanitise-stdoutdo/don't strip control chars from standard output/error-no-antispoof   omit anti-spoofing prompt after authentication-m file   read remote command(s) from file-s        remote command is an SSH subsystem (SSH-2 only)-N        don't start a shell/command (SSH-2 only)-nc host:portopen tunnel in place of session (SSH-2 only)-sshlog file-sshrawlog filelog protocol details to a file-logoverwrite-logappendcontrol what happens when a log file already exists-shareexiststest whether a connection-sharing upstream existsPlink:命令行连接工具
版本 0.81
使用方法:plink [选项] [用户@]主机 [命令]("主机" 也可以是 PuTTY 保存的会话名称)
选项:-V         显示版本信息并退出-pgpfp     显示 PGP 密钥指纹并退出-v         显示详细消息-load sessname  从保存的会话加载设置-ssh -telnet -rlogin -raw -serial强制使用特定协议-ssh-connection强制使用基本的 ssh-连接协议-P 端口     连接到指定端口-l 用户名   使用指定用户名连接-batch      禁用所有交互式提示-proxycmd 命令使用 '命令' 作为本地代理-sercfg 配置字符串(例如,19200,8,n,1,X)指定串行配置(仅限串行)
以下选项仅适用于 SSH 连接:-pwfile 文件    从指定文件读取密码登录-D [监听-IP:]监听端口动态基于 SOCKS 的端口转发-L [监听-IP:]监听端口:目标主机:目标端口将本地端口转发到远程地址-R [监听-IP:]监听端口:目标主机:目标端口将远程端口转发到本地地址-X -x       启用 / 禁用 X11 转发-A -a       启用 / 禁用代理转发-t -T       启用 / 禁用伪终端分配-1 -2       强制使用特定的 SSH 协议版本-4 -6       强制使用 IPv4 或 IPv6-C        启用压缩-i 密钥文件  用于用户身份验证的私钥文件-noagent   禁用 Pageant 的使用-agent     启用 Pageant 的使用-no-trivial-auth如果 SSH 认证轻易成功则断开连接-noshare   禁用连接共享-share     启用连接共享-hostkey 密钥ID手动指定主机密钥(可重复)-sanitise-stderr, -sanitise-stdout, -no-sanitise-stderr, -no-sanitise-stdout对标准输出/错误执行/不执行控制字符剥离-no-antispoof   认证后省略反欺骗提示-m 文件     从文件读取远程命令-s        远程命令是一个 SSH 子系统(仅 SSH-2)-N        不启动shell/命令(仅 SSH-2)-nc 主机:端口以隧道代替会话打开(仅 SSH-2)-sshlog 文件-sshrawlog 文件将协议详细信息记录到文件中-logoverwrite-logappend控制当日志文件已存在时的行为-shareexists测试是否存在连接共享的上游脚本示例
@echo offREM set
set PLINK_PATH="C:\Program Files\PuTTY\plink.exe"
set UR_IP=192.168.1.106
set SSH_PORT=22
set USERNAME=root
set PASSWORD=easybot
set SHUTDOWN_COMMAND="sudo shutdown -h now"REM shutdown
%PLINK_PATH% -P %SSH_PORT% -l %USERNAME% -pw %PASSWORD% %UR_IP% %SHUTDOWN_COMMAND%echo shutdown
pause