putty连接linux设置文件夹,【整理】Windows用ssh连接Linux,想要从Linux上面上传/下载文件 - putty的子工具psftp...
【背景】
用putty通過ssh連接遠程的Linux,可以登錄正常操作,包括編輯文件等。
但是由于速度很慢,所以在putty下,通過遠程Linux的vi編輯文件,反應太慢,受不了。
期望的是,可以把該文件下載到windows的本機,然后本地編輯,編輯完后,提交覆蓋源文件,即可實現高效的本地編輯文件了。
【解決方案】
網上找了下,找到這個:
即通過psftp,是putty的眾多的工具之一(其他的putty子工具還有PAGEANT.EXE,PLINK.EXE,PSCP.EXE,PUTTY.EXE,PUTTYGEN.EXE),可以實現我的需求,即從Linux服務器上面,上傳下載文件。
【psftp用法簡介】
運行psftp之前,讓我們來看看其說明:
D:DevToolputty>psftp -hPuTTY Secure File Transfer (SFTP) client
Development snapshot 2011-04-07:r9125
Usage: psftp [options] [user@]host
Options:
-V??????? print version information and exit
-pgpfp??? print PGP key fingerprints and exit
-b file?? use specified batchfile
-bc?????? output batchfile commands
-be?????? don’t stop batchfile processing if errors
-v??????? show verbose messages
-load sessname? Load settings from saved session
-l user?? connect with specified username
-P port?? connect to specified port
-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
在windows下,雙擊運行psftp,即可打開psftp,運行界面就是和普通windows下面的cmd一樣。
進入psftp后,輸入help,可以看到其支持很多的命令:
psftp> help
!????? run a local command
bye??? finish your SFTP session
cd???? change your remote working directory
chmod? change file permissions and modes
close? finish your SFTP session but do not quit PSFTP
del??? delete files on the remote server
dir??? list remote files
exit?? finish your SFTP session
getdownload a file from the server to your local machine
help?? give help
lcd??? change local working directory
lpwdprint local working directory
ls???? list remote files
mget?? download multiple files at once
mkdir? create directories on the remote server
mput?? upload multiple files at once
mv???? move or rename file(s) on the remote server
openconnect to a host
putupload a file from your local machine to the server
pwdprint your remote working directory
quit?? finish your SFTP session
reget? continue downloading files
ren??? move or rename file(s) on the remote server
reput? continue uploading files
rm???? delete files on the remote server
rmdir? remove directories on the remote server
1. 查看具體的某個命令的語法
用help加上命令名,即可查看具體的某個命令的語法:
psftp> help open
open [@] []
Establishes an SFTP connection to a given host. Only usable
when you are not already connected to a server.
psftp> help mget
mget [ -r ] [ — ] [ … ]
Downloads many files from the server, storing each one under
the same name it has on the server side. You can use wildcards
such as “*.c” to specify lots of files at once.
If -r specified, recursively fetch files and directories.
2. 連接linux服務器
open Linux_IP_or_ServerName
去打開一個遠程的Linux,后面參數是IP地址或者域名,比如:
3. 更改在Linux的所處的目錄 + 查看Linux上面的文件
比如
cd /
即可切換到根目錄
ls
即可查看當前文件夾的文件。
這些命令的用法和Linux下面一樣,不多介紹。
4. 查看當前windows目錄 + 更改為你想要的目錄
psftp> lpwd
Current local directory is D:tmp
psftp> lcd C:New local directory is C:
5. 感嘆號+windows的命令,實現在psftp中運行windows的命令
引用的帖子中,說無法查看本地當前文件夾的文件,其實是不對的。
其實可以通過!dir,去查看windows下當前文件夾的文件的
psftp> lcd D:tmpbatch_testNew local directory is D:tmpbatch_test
psftp> !dir?Volume in drive D has no label.
Volume Serial Number is 7048-D15B
Directory of D:tmpbatch_test
04/20/2011? 03:29 PM???
04/20/2011? 03:29 PM???
04/14/2011? 03:48 PM???????????? 2,876 batch_file_test.bat
1 File(s)????????? 2,876 bytes
2 Dir(s)? 35,291,792,384 bytes free
6. 從windows到Linux的上傳/下載文件
psftp> ls
Listing directory /home/e516537
drwx——??? 4 e516537? e516537????? 4096 Apr 20 06:50 .
drwxr-xr-x?? 19 root???? root???????? 4096 Apr 14 12:20 ..
-rw——-??? 1 e516537? users??????? 3356 Apr 19 03:28 .bash_history
-rw-r–r–??? 1 e516537? e516537??????? 33 Mar 31 21:00 .bash_logout
-rw-r–r–??? 1 e516537? e516537?????? 248 Apr 14 08:57 .bash_profile
-rw-r–r–??? 1 e516537? e516537?????? 124 Mar 31 21:00 .bashrc
-rw-r–r–??? 1 e516537? e516537?????? 515 Mar 31 21:00 .emacs
drwxr-xr-x??? 3 e516537? e516537????? 4096 Mar 31 21:00 .kde
drwxr-xr-x??? 4 e516537? e516537????? 4096 Mar 31 21:00 .mozilla
-rw——-??? 1 e516537? users??????? 5830 Apr 20 06:50 .viminfo
-rw-r–r–??? 1 e516537? e516537?????? 658 Mar 31 21:00 .zshrc
-rwxr–r–??? 1 e516537? users???????? 103 Apr 20 07:11 just_for_test.txtpsftp> get just_for_test.txtremote:/home/e516537/just_for_test.txt => local:just_for_test.txt
psftp> !dir
Volume in drive D has no label.
Volume Serial Number is 7048-D15B
Directory of D:tmpbatch_test
04/20/2011? 03:31 PM???
04/20/2011? 03:31 PM???
04/14/2011? 03:48 PM???????????? 2,876 batch_file_test.bat04/20/2011? 03:31 PM?????????????? 103 just_for_test.txt
2 File(s)????????? 2,979 bytes
2 Dir(s)? 35,291,792,896 bytes free
psftp> put batch_file_test.batlocal:batch_file_test.bat => remote:/home/e516537/batch_file_test.bat
7.用mget去批量下載多個文件(或用mput一次性上傳多個文件)
psftp> cd /mnt/linuxdev/Blackfin/FWZ/carifan_15947
Remote directory is now /mnt/beta/linuxdev/Blackfin/FWZ/carifan_15947
psftp> ls
Listing directory /mnt/beta/linuxdev/Blackfin/FWZ/carifan_15947
drwxrwxrwx??? 1 root???? RandD??????? 4096 Aug? 4 21:36 .
drwxrwxrwx??? 1 root???? RandD??????? 4096 Jul 26 04:25 ..
drwxrwxrwx??? 1 root???? RandD??????? 4096 Jul 26 04:29 15947
-rwxrwxrwx??? 1 root???? RandD??????? 1537 Jul 26 04:33 15947.fwr
…
-rwxrwxrwx??? 1 root???? RandD????????? 64 Jul 26 04:33 vssver.scc
psftp> lcd D:DevToolfwzmakerfile_to_build
New local directory is D:DevToolfwzmakerfile_to_build
psftp> help
!????? run a local command
bye??? finish your SFTP session
cd???? change your remote working directory
。。。
ls???? list remote files
mget?? download multiple files at once
mkdir? create directories on the remote server
mput?? upload multiple files at once
。。。
psftp> help mgetmget [ -r ] [ — ] [ … ]
Downloads many files from the server, storing each one under
the same name it has on the server side. You can use wildcards
such as “*.c” to specify lots of files at once.
If -r specified, recursively fetch files and directories.
psftp> mget -r *remote:/mnt/beta/linuxdev/Blackfin/FWZ/carifan_15947/15947/Datastrip_prefix_test.doc => local:15947Datastrip_prefix_tes
t.doc
。。。
remote:/mnt/beta/linuxdev/Blackfin/FWZ/carifan_15947/vssver.scc => local:vssver.scc
【總結】
本身Putty就是個好東西,免費,而且功能多,而這個putty的子工具psftp也很不錯。有機會大家自己探索其更多的功能吧。
另外,看上面引用的那個帖子介紹,好像scp可以實現兩個Linux之間的文件傳輸,有機會有興趣的人,也去試試吧。
總結
以上是生活随笔為你收集整理的putty连接linux设置文件夹,【整理】Windows用ssh连接Linux,想要从Linux上面上传/下载文件 - putty的子工具psftp...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: OpenStack tokens id获
- 下一篇: php职业性格测试,三个职业测试方法,助