Forum

Yampiz Forum

Sharing let knowledge Spreaded, Reading let spirits growth, Creative let culture extended, Let us
  • 禁止廣告文
  • 知識傳播
  • 閱讀
  • 心靈成長
  • 創作
  • 文化傳承
Forum Dictionary / PC / Linux 討論版 / Shell /

SSH 檔案傳輸的方法

New Subject
Random
Previous
Next
|
SSH 檔案傳輸的方法

scp [來源檔名] [目的id]@[目的ip]:[目的目錄]
or
scp -r [來源目錄] [目的id]@[目的ip]:[目的目錄]

用法跟cp都一樣啦... 也可以從遠端摳回來..

scp [來源id]@[來源ip]:[來源檔名] [目的目錄]
or
scp -r [來源id]@[來源ip]:[來源目錄] [目的目錄]

也可以遠端a摳到遠端b...
scp [來源id]@[來源ip]:[來源檔名] [目的id]@[目的ip]:[目的目錄]
or
scp -r [來源id]@[來源ip]:[來源目錄] [目的id]@[目的ip]:[目的目錄]

ex: 從 192.168.1.1 copy /test.txt 到 192.168.1.2 的 /home/asimon/
在.1執行.... .2的登入帳號是 asimon
scp /test.txt asimon@192.168.1.2:/home/asimon
輸入 .2 asimon 的密碼 就可以傳檔囉 :)

很好用的! 只要ssh得上.. 有登入帳號.. 應該就通 :)

ex2:
SSH 登入

ssh username@hostname

登入後

傳過去

scp -p source.file user@mytarget.com:/home/liu

抓過來

scp user@mytarget.com:/home/apol/source.file /home/target_dir_in_localhost

[3/29補充]
ftp:

ftp ip

> get filename

> put filename

> bye

ssh:

傳輸到遠程:tar czf - /path/filename | ssh server "tar zxf -"

這樣回把文件傳送到登陸server上用戶的根目錄裡。

SSH PUSH(從本地發送到遠程):
代碼:

$ tar cvf - . | gzip -c -1 | ssh user@host "cat > remotefile.gz"
$ tar czvf - . | ssh user@host "cat > remote.tar.gz"
$ ssh target_address cat <>" remotefile
$ ssh target_address cat <>" remotefile
$ cat localfile | ssh target_address cat ">" remotefile
$ cat localfile | ssh target_address cat - ">" remotefile
註: 以上命令行中的 大於號> 兩邊有雙引號(" ") , 小於號< 兩邊則沒有。 $ dd if=localfile | ssh target_address dd ōf=remotefile $ ssh target_address cat remotefile.tar )"
$ ( cd SOURCEDIR && tar czvf - . ) | ssh target_address "(cd DESTDIR && cat - > remotefile.tgz )"
$ ( cd SOURCEDIR && tar cvf - . | gzip -1 -) | ssh target_address "(cd DESTDIR && cat - > remotefile.tgz )"
$ ssh target_address "( nc -l -p 9210 > remotefile & )" && cat source-file | gzip -1 - | nc target_address 9210
$ cat localfile | gzip -1 - | ssh target_address cat ">" remotefile.gz

SSH PULL(從遠程獲取到本地):
代碼:

$ ssh target_address cat remotefile > localfile
$ ssh target_address dd if=remotefile | dd of=localfile
$ ssh target_address cat "<" remotefile > localfile
$ ssh target_address cat "<" remotefile.gz | gunzip >localfile

SSH COMPARE(本地和遠程文件比較):
代碼:

用遠程計算機CPU執行比較指令
$ ssh target_address cat remotefile | diff - localfile
$ cat localfile | ssh target_address diff - remotefile

用本地計算機CPU執行比較指令
$ ssh target_address cat get file.gif "| xv -"
$ ftp> get README "| more"


FTP PUSH(從本地發送到遠程):
代碼:

$ ftp> put "| tar cvf - ." myfile.tar
$ ftp> put "| tar cvf - . | gzip " myfile.tar.gz

FTP PULL(從遠程獲取到本地):
代碼:

$ ftp> get myfile.tar "| tar xvf -"
 

  • This is a reposted article.
  • Keywords : target_address, remotefile, localfile, 目錄, 代碼, asimon, 來源ip, 來源id, 來源目錄, 來源檔名, source, myfile, filename, 登入帳號, 指令, mytarget, SOURCEDIR, DESTDIR, 遠程文件, 輸入
0 0
2011-05-09T17:37:00+0000


  • Now, you can post comments by Facebook Account when your Yampiz account was logout or unvariable. whatever, we suggest to post comment by Yampiz Account to get more bounds to join new events of Heyxu
Comment
 
Verify
  • Auto Platform
    For better browsing experience, it will auto detects your device to display webpage.
  • Bug Report
    Tell us about the idea, problem and errors you found.
  • Comodo Secure
    The sensitive data transmission adopts by SSL-2048 authenticated encryption.
  • Copyright
    © 2009 YamPiz Digital Inc. & Jaby Group. All rights reserved.
  • Revised Version
    V2.2.061
    03 Aug 2023 (GMT+8)