putty中的plink.exe功能和用法

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 -serial
            force use of a particular protocol
  -ssh-connection
            force 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 command
            use '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-port
            Dynamic SOCKS-based port forwarding
  -L [listen-IP:]listen-port:host:port
            Forward local port to remote address
  -R [listen-IP:]listen-port:host:port
            Forward 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-auth
            disconnect if SSH authentication succeeds trivially
  -noshare  disable use of connection sharing
  -share    enable use of connection sharing
  -hostkey keyid
            manually specify a host key (may be repeated)
  -sanitise-stderr, -sanitise-stdout, -no-sanitise-stderr, -no-sanitise-stdout
            do/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:port
            open tunnel in place of session (SSH-2 only)
  -sshlog file
  -sshrawlog file
            log protocol details to a file
  -logoverwrite
  -logappend
            control what happens when a log file already exists
  -shareexists
            test whether a connection-sharing upstream exists
Plink:命令行连接工具
版本 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 off

REM 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

Putty使用技巧, 1. PuTTY 中文教程 1. 更新记录 2. 版权声明 3. 序言 4. 一些基本知识 5. 简介 6. 安装 7. 第一印象,开始登录一台远程主机 8. 首次登录一台主机时 9. 又看到了中文乱码 10. 怎么还是乱码? 11.PuTTY 里面怎样选中,复制粘贴? 2. 实时保存会话 1. 关于注销登录的一些事情 2. 窗口保存的输出有点少,前面的都看不到了 3. 新建一个会话时,还有些东西再啰嗦一下 1. 保持连接,不要自动断开 2. 自动登录用户 3. 自动设置环境变量 4. 设置代理服务器 5. 自动执行一个命令 6. 数据自动压缩传输,变相的提高传输速率 7. 无需口令登录 8. X11 转发能够让你在 Windows 上使用 Linux 的程序 9.SSH Tunnels(SSH 隧道),突破防火墙 4. 象特洛伊木马一样建立一条 SSH 反向隧道 5.PuTTY 作为一个安全的代理服务器来使用 1. 设置 PuTTY 的默认设置 2. 备份 PuTTY 的设置 3. 删除 PuTTY 的设置 6.PuTTYgen 来生成密钥,以后可以不用密码登录服务器了 1. 开始用 PuTTYgen 创建密钥 2. 用密钥登录服务器的流程 7. Pagent 加载密钥,每次开机后只需要输入一次密钥口令 8.SSH 来传输文件 1. PSCP 的使用 2. 再来看看 PSFTP 3. 其他可选的 SFTP 客户端 9.Plink 更方便快捷的执行远程主机上的命令 10. 用假象去迷惑敌人 11. Tips(小技巧) 12. FAQ(常见问题) 13. 附录
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ersaijun

您的鼓励是我创作的最大动力!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值