欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

putty使用

程序员文章站 2024-03-18 18:37:52
...
  • 上传下载文件:
    下载
pscp -scp [email protected]:/var/tmp/capture.hex c:\temp

上传

pscp -scp c:/temp/capture [email protected]:/var/tmp/capture

-scp:指定传输协议,pscp默认协议sftp

  • openssh私钥转putty私钥:
puttygen keyname -o keyname.ppk
  • putty工具与bat脚本配合使用
::get current directory %CD%
::define host ip, username,password
set host_ip=10.0.0.153
set username=root
set password=123456

::just aceept the host key at the first time.
echo y | PLINK.EXE -pw %password% %username%@%host_ip% "pwd"

::transfer file to server
::PSCP.EXE -pw %password% files\test.sh %username%@%host_ip%:/root

::transfer folder to server
::PSCP.EXE -pw %password% -r files %username%@%host_ip%:/root

::run a single command
::PLINK.EXE -no-antispoof -pw %password% %username%@%host_ip% "chmod 777 /root/test.sh"

::run commands from a file
PLINK.EXE -no-antispoof -pw %password% %username%@%host_ip% -m commands.txt > command_logs.txt

@pause
相关标签: putty ssh