2008年11月5日水曜日

plink.exe pscp.exe で Windowsコマンドラインからssh、scp

Windowsコマンドプロンプトから急にLinuxサーバにファイルの転送がしたくなった。
同様に、突然ssh経由でログインしたくなった。
 

そんな機会もあろうかと、有名なsshクライアントのputtyにはおまけが付いている。
plink.exe , pscp.exe がそれだ。単純にコマンドラインから ssh/scp がやりたければ十分なツールだ。
 

たまに使うので記事にしておく、適当なところに設置してパスを通しておくと便利かも。
 
 

sshクライアント plink.exe (PuTTY Link)


大まかな使い方は ssh コマンドと一緒。ヘルプを載せておく。
機能はイマイチ、Screen などのユーティリティもh上に変な動きになるが、動作確認程度として考えたら十分だ。コマンド叩いてくるだけのような使い方でもよい。
※機能十分なクライアントが使いたければ putty.exe を叩けばいい。
 
PuTTY Link: command-line connection utility
Release 0.60
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
force use of a particular protocol
-P port connect to specified port
-l user connect with specified username
-batch disable all interactive prompts
The following options only apply to SSH connections:
-pw passw login with specified password
-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 protocol version
-4 -6 force use of IPv4 or IPv6
-C enable compression
-i key private key file for authentication
-noagent disable use of Pageant
-agent enable use of Pageant
-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)

 
 

scpクライアント pscp.exe (PuTTY Secure Copy client)


これも scp コマンドと似たような使い勝手。ヘルプのっけるだけでも大体分かるな。
 

PuTTY Secure Copy client
Release 0.60
Usage: pscp [options] [user@]host:source target
pscp [options] source [source...] [user@]host:target
pscp [options] -ls [user@]host:filespec
Options:
-V print version information and exit
-pgpfp print PGP key fingerprints and exit
-p preserve file attributes
-q quiet, don't show statistics
-r copy directories recursively
-v show verbose messages
-load sessname Load settings from saved session
-P port connect to specified port
-l user connect with specified username
-pw passw login with specified password
-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 authentication
-noagent disable use of Pageant
-agent enable use of Pageant
-batch disable all interactive prompts
-unsafe allow server-side wildcards (DANGEROUS)
-sftp force use of SFTP protocol
-scp force use of SCP protocol