日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

使用SecureCRT的SFTP在WINDOWS与LINUX之间传输文件(转载)

發(fā)布時(shí)間:2025/3/21 47 豆豆
生活随笔 收集整理的這篇文章主要介紹了 使用SecureCRT的SFTP在WINDOWS与LINUX之间传输文件(转载) 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

參考文獻(xiàn):

http://ice-k.iteye.com/blog/1068275

http://www.cnblogs.com/chen1987lei/archive/2010/11/26/1888391.html

背景:

有一臺(tái)主機(jī),安裝了windows7,在其安裝了virtualbox,然后安裝了 ubuntu虛擬機(jī)。在windows7上安裝SecureCRT來ssh連接ubuntu虛擬機(jī)。一般在windows上面下載軟件,然后通過 vsftp上傳到ubuntu虛擬機(jī)上。但是這樣非常麻煩,現(xiàn)在考慮使用sftp協(xié)議來直接傳輸。

方案:

使用SecureCRT軟件ssh連接到ubuntu虛擬機(jī)。然后在SecureCRT上面打開SFTP會(huì)話,如下圖所示:  

SFTP命令

進(jìn)入到sftp命令窗口以后,就可以通過sftp命令來進(jìn)行文件互傳的操作。下面主要介紹一下sftp命令的含義。 sftp> help Available commands: ascii Set transfer mode to ASCII binary Set transfer mode to binary cd path Change remote directory to 'path' lcd path Change local directory to 'path' detail remote-path Display system information about remote file or folder ldetail local-path Display system information about local file or folder chgrp group path Change group of file 'path' to 'group' chmod mode path Change permissions of file 'path' to 'mode' chown owner path Change owner of file 'path' to 'owner' exit Quit sftp help Display this help text include filename Include commands from 'filename' Alternate: < filename get [-r][-a | -b] remote-path Download file -r downloads directory recursively force ascii (-a) or binary (-b) mode ln [-s] existingpath linkpath Hardlink / symlink remote file ls [options] [path] Display remote directory listing lls [options] [path] Display local directory listing mkdir path Create remote directory lmkdir path Create local directory mv oldpath newpath Move remote file lmv oldpath newpath Move local file open [user@]host[:port] Connect to remote host put [-r][-a | -b] local-path Upload file -r uploads directory recursively force ascii (-a) or binary (-b) mode pwd Display remote working directory lpwd Print local working directory quit Quit sftp rename oldname newname Rename remote file lrename oldname newname Rename local file rmdir path Remove remote directory lrmdir path Remove local directory rm path Delete remote file lrm path Delete local file su username Substitutes the current user This is only supported with VShell for Windows 3.5 or later. type [transfer-mode] Display or set file transfer mode view remote-path Download and open file version Display protocol version

翻譯一下就是:

sftp-- help 可用命令: cd 路徑 更改遠(yuǎn)程目錄到“路徑” lcd 路徑 更改本地目錄到“路徑” chgrp group path 將文件“path”的組更改為“group” chmod mode path 將文件“path”的權(quán)限更改為“mode” chown owner path 將文件“path”的屬主更改為“owner” exit 退出 sftp help 顯示這個(gè)幫助文本 get 遠(yuǎn)程路徑 下載文件 ln existingpath linkpath 符號(hào)鏈接遠(yuǎn)程文件 ls [選項(xiàng)] [路徑] 顯示遠(yuǎn)程目錄列表 lls [選項(xiàng)] [路徑] 顯示本地目錄列表 mkdir 路徑 創(chuàng)建遠(yuǎn)程目錄 lmkdir 路徑 創(chuàng)建本地目錄 mv oldpath newpath 移動(dòng)遠(yuǎn)程文件 open [用戶@]主機(jī)[:端口] 連接到遠(yuǎn)程主機(jī) put 本地路徑 上傳文件 pwd 顯示遠(yuǎn)程工作目錄 lpwd 打印本地工作目錄 quit 退出 sftp rmdir 路徑 移除遠(yuǎn)程目錄 lrmdir 路徑 移除本地目錄 rm 路徑 刪除遠(yuǎn)程文件 lrm 路徑 刪除本地文件 symlink existingpath linkpath 符號(hào)鏈接遠(yuǎn)程文件 version 顯示協(xié)議版本

我們主要用到的就是一下六個(gè)命令

cd 路徑 更改遠(yuǎn)程目錄到“路徑” lcd 路徑 更改本地目錄到“路徑” ls [選項(xiàng)] [路徑] 顯示遠(yuǎn)程目錄列表 lls [選項(xiàng)] [路徑] 顯示本地目錄列表 put 本地路徑 上傳文件 get 遠(yuǎn)程路徑 下載文件

這里在詳細(xì)說明一下遠(yuǎn)程目錄本地目錄

遠(yuǎn)程目錄:ls查看到的是ubuntu虛擬機(jī)上面的目錄

本地目錄:lls查看到的是windows實(shí)體機(jī)上面的目錄。

實(shí)例:

假設(shè)我需要實(shí)現(xiàn)windows下的e:\sftp\test1.txt和ubuntu下/home/enadmin/test2.txt的互換,可以進(jìn)行一下操作:

put操作:windows->linux

查看目錄權(quán)限

root@BJCGNMON01:/home# ll total 20 drwxr-xr-x 5 root root 4096 Apr 18 15:21 ./ drwxr-xr-x 24 root root 4096 Jan 3 14:14 ../ drwxr-xr-x 9 enadmin enadmin 4096 Apr 18 15:22 enadmin/ drwxr-xr-x 2 root root 4096 Apr 18 15:21 sftp/--可以看到sftp的權(quán)限是root的 drwxr-xr-x 2 root root 4096 Apr 18 14:57 test/ root@BJCGNMON01:/home# chown -R enadmin.enadmin sftp/ root@BJCGNMON01:/home# ll total 20 drwxr-xr-x 5 root root 4096 Apr 18 15:21 ./ drwxr-xr-x 24 root root 4096 Jan 3 14:14 ../ drwxr-xr-x 9 enadmin enadmin 4096 Apr 18 15:22 enadmin/ drwxr-xr-x 2 enadmin enadmin 4096 Apr 18 15:21 sftp/--修改以后權(quán)限變成enadmin的了 drwxr-xr-x 2 root root 4096 Apr 18 14:57 test/

拷貝文件

sftp> put test* --初始想將文件從windows系統(tǒng)put到ubuntu系統(tǒng),發(fā)現(xiàn)失敗,提示拒絕訪問 Uploading test1.txt to /home/test1.txt put: failed to upload e:/sftp/test1.txt. 拒絕訪問。 Uploading test2.txt to /home/test2.txt put: failed to upload e:/sftp/test2.txt. 拒絕訪問。 Uploading test3.txt to /home/test3.txt put: failed to upload e:/sftp/test3.txt. 拒絕訪問。 sftp> pwd --查看當(dāng)前目錄是/home目錄,權(quán)限是root的 /home sftp> cd /home/enadmin/ --我切換到enadmin目錄下 sftp> ls Graphs.pm msmtp ntp sent smokeping.tar.gz smokepingrtt.tar.gz smokepingrtt2.tar.gz Target wqy wqy-zenhei-0.8.38-1.deb sftp> lls test1.txt test2.txt test3.txt sftp> put test* -再次嘗試將windows下的文件put到/homg/enadmin目錄下,這次成功 Uploading test1.txt to /home/enadmin/test1.txt 100% 4 bytes 4 bytes/s 00:00:00 e:/sftp/test1.txt: 4 bytes transferred in 0 seconds (4 bytes/s) Uploading test2.txt to /home/enadmin/test2.txt 100% 4 bytes 4 bytes/s 00:00:00 e:/sftp/test2.txt: 4 bytes transferred in 0 seconds (4 bytes/s) Uploading test3.txt to /home/enadmin/test3.txt 100% 5 bytes 5 bytes/s 00:00:00 e:/sftp/test3.txt: 5 bytes transferred in 0 seconds (5 bytes/s) sftp> cd /home/sftp/--在修改sftp目錄權(quán)限以后,再次切換到sftp目錄下 sftp> ls sftp> lls test1.txt test2.txt test3.txt sftp> put test* --這回put成功。所以跟權(quán)限相關(guān) Uploading test1.txt to /home/sftp/test1.txt 100% 4 bytes 4 bytes/s 00:00:00 e:/sftp/test1.txt: 4 bytes transferred in 0 seconds (4 bytes/s) Uploading test2.txt to /home/sftp/test2.txt 100% 4 bytes 4 bytes/s 00:00:00 e:/sftp/test2.txt: 4 bytes transferred in 0 seconds (4 bytes/s) Uploading test3.txt to /home/sftp/test3.txt 100% 5 bytes 5 bytes/s 00:00:00 e:/sftp/test3.txt: 5 bytes transferred in 0 seconds (5 bytes/s)

注意點(diǎn):這里需要注意權(quán)限的問題。加入我是使用enadmin賬戶初始連接ubuntu的,那么我put的文件只能放到文件夾權(quán)限是enadmin 的目錄下,不能放到文件夾權(quán)限是root的目錄下。如果想放到文件夾權(quán)限是root的目錄下,那么初始就使用root賬戶連接ubunut,然后再創(chuàng)建 sftp會(huì)話,這樣就可以了。

get操作:linux->windows

get操作沒有權(quán)限設(shè)定

sftp> pwd /home/enadmin sftp> lpwd e:/Documents sftp> lcd e:/sftp --切換目錄 sftp> lls rc.local test1.txt test2.txt test3.txt sftp> ls Graphs.pm msmtp ntp sent smokeping.tar.gz smokepingrtt.tar.gz smokepingrtt2.tar.gz Target test1.txt test2.txt test3.txt wqy wqy-zenhei-0.8.38-1.deb sftp> get Graphs.pm --下載文件到windows Downloading Graphs.pm from /home/enadmin/Graphs.pm 100% 13KB 13KB/s 00:00:00 /home/enadmin/Graphs.pm: 13503 bytes transferred in 0 seconds (13 KB/s) sftp> lls --查看windows目錄 Graphs.pm rc.local test1.txt test2.txt test3.txt sftp>

轉(zhuǎn)載于:https://www.cnblogs.com/cupsuccess/p/6062031.html

總結(jié)

以上是生活随笔為你收集整理的使用SecureCRT的SFTP在WINDOWS与LINUX之间传输文件(转载)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。