使用Xshell自帶的工具茉帅,不借助額外的工具叨叙,進(jìn)行文件上傳。
一堪澎、說(shuō)明
點(diǎn)擊工具欄的新建文件傳輸(Ctrl+Alt+F)
擂错,或者快捷鍵Ctrl+Alt+F
如下所示。
點(diǎn)擊之后樱蛤,就會(huì)彈出一下的窗口钮呀,這里我們選擇取消。
Xftp
是一個(gè)文件上傳的界面插件昨凡。需要單獨(dú)下載爽醋,這里我們就不選用它。點(diǎn)擊“取消”后土匀,會(huì)自動(dòng)進(jìn)入到一個(gè)上傳的命令行界面子房。
Xshell 5 (Build 0964)
Copyright (c) 2002-2016 NetSarang Computer, Inc. All rights reserved.
Type `help' to learn how to use Xshell prompt.
[c:\~]$
Connecting to 47.32.152.32:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.
Your current local directory is
C:\Users\houxin\Documents\NetSarang\Xshell\Sessions
Type `help' to browse available commnands.
sftp:/root>
上面有顯示當(dāng)前的默認(rèn)的本地目錄是:C:\Users\houxin\Documents\NetSarang\Xshell\Sessions
。這個(gè)后面有用。
二证杭、上傳文件
上傳文件使用put
命令田度。
當(dāng)前目錄是root
的家目錄,可以使用cd
等一系列命令繼續(xù)切換到你的目標(biāo)路徑解愤。這個(gè)我們切換到當(dāng)前目錄下的images
目錄镇饺。
sftp:/root> pwd
Remote directory is /root
sftp:/root> cd images
sftp:/root/images> ls -a
drwxr-xr-x 2 root root 6 Sep 21 16:00 .
dr-xr-x--- 12 root root 4096 Sep 21 15:21 ..
輸入put
后回車(chē),會(huì)彈出一個(gè)windows的文件選擇框送讲。選擇你需要的文件奸笤。然后點(diǎn)擊確定就行了。
結(jié)果如下:
sftp:/root/images> put
Uploading 6a7ff800af8ca8aad0c901597a0ff63a.jpeg to remote:/root/images/6a7ff800af8ca8aad0c901597a0ff63a.jpeg
sftp: sent 50.3 KB in 0.03 seconds
這里顯示已經(jīng)將當(dāng)前的文件上傳到/root/images/
里面了哼鬓。
sftp:/root/images> ls -a
drwxr-xr-x 2 root root 51 Sep 21 16:02 .
dr-xr-x--- 12 root root 4096 Sep 21 15:21 ..
-rw-r--r-- 1 root root 51580 Sep 21 16:02 6a7ff800af8ca8aad0c901597a0ff63a.jpeg
文件已經(jīng)上傳成功了监右。
三、下載文件
1异希、修改下載目錄
還記得開(kāi)篇的C:\Users\houxin\Documents\NetSarang\Xshell\Sessions
地址嗎健盒?這個(gè)就是下載的默認(rèn)目錄。
如果你需要修改的話称簿,可以使用lcd
命令扣癣。
在命令行輸入lcd
后,選擇一個(gè)文件夾憨降,就是默認(rèn)的下載地址父虑。 這里我把下載地址換成windows的下載地址。
sftp:/root/images> lcd
Local directory is now C:\Users\houxin\Downloads
2授药、下載文件
下載文件士嚎,使用get [文件路徑]
命令。
當(dāng)前路徑下有abc.txt
的文件烁焙,我下載它航邢。
sftp:/root/images> ls -a
drwxr-xr-x 2 root root 66 Sep 21 16:25 .
dr-xr-x--- 12 root root 4096 Sep 21 15:21 ..
-rw-r--r-- 1 root root 7 Sep 21 16:25 abc.txt
sftp:/root/images> get abc.txt
Fetching /root/images/abc.txt to abc.txt
sftp: received 7 bytes in 0.01 seconds
這里顯示下載完成了。
我們?cè)?code>C:\Users\houxin\Downloads目錄下骄蝇,也看到了剛剛我們下載的文件膳殷。
這個(gè)是下載當(dāng)前目錄下的文件。如果想下載其他目錄的文件九火,只需要加上絕對(duì)或者相對(duì)路徑即可赚窃。
這里我們下載,當(dāng)前目錄中的aaa
目錄下的aaa.txt
岔激,命令如下:
sftp:/root/images> get ./aaa/aaa.txt
Fetching /root/images/./aaa/aaa.txt to aaa.txt
sftp: received 0 bytes in 0.02 seconds
可以靈活使用勒极。