拥有多台服务器或测试的朋友也许常常会遇到在不同机器之间拷贝文件的情况,通常的做法通过FTP传输,当然也可以通过HTTP,SAMBA等,但这些都有一个通病,即每次必须输入密码或经过复杂的配置,很不方便.
下面我介绍一种安全又快速的远程复制文件的方法供大家参考:
1.命令:SCP --secure copy (remote file copy program)
些命令是openssh-clients附带的,机器之间传输完全是加密的
2.配置方法:
1)保证安装了SSH,最好是SSH2比较好
2)开启SSH证书认证
即,在配置文件(/etc/ssh/sshd_config)里,设定
RSAAuthentication yes
PubkeyAuthentication yes
3)生成并分发密钥对
$ ssh-keygen -d
屏幕提示:
Generating public/private dsa key pair.
Enter file in which to save the key (/home/mms/.ssh/id_dsa):
# 按回车保存为: /home/mms/.ssh/id_dsa,即当前用户mms的私钥
Enter passphrase (empty for no passphrase):
# 按回车,表示读取密钥时不需要密钥的密码
Enter same passphrase again:
# 确认密钥的密码,必须和上面的输入相同
Your identification has been saved in /home/mms/.ssh/id_dsa.
# 私钥保存信息
Your public key has been saved in /home/mms/.ssh/id_dsa.pub.
# 公钥保存信息
The key fingerprint is:
# 密钥指纹
分发公钥
为了使用密钥,必须将公钥分发到所要登录的远程服务器上.
copy id_dsa.pub到remote_host:/home/[user]/.ssh/
这里[user]为sftp使用的登录用户.若目录/home/[user]/.ssh/不存在,请先创建之.
b).将copy来的公钥文件改名为authorized_keys,如果已经存在authorized_keys,可以使用命令: cat id_dsa.pub >> authorized_keys 将其内容附加到authorized_keys的末尾
c).修改公钥文件的访问权限
chmod 644 authorized_keys
d)重启SSH服务
3.示例
scp test.txt root@192.168.6.90:/tmp
以上命令会将本地文件test.txt拷贝到远程机器192.168.6.90的/tmp目录下.
69.147.76.* 于 2007-09-04 01:22:54发表:
chocolate cake
195.225.177.* 于 2007-09-03 20:33:53发表:
culinary art collegeculinary art college auto car cheap insurance quoteauto car cheap insurance quote cheap wedding favorcheap wedding favor
72.51.37.* 于 2007-09-03 19:36:43发表:
chocolate
195.225.177.* 于 2007-09-03 15:32:57发表:
online college degreesonline college degrees college online degreecollege online degree college tuitioncollege tuition
195.225.177.* 于 2007-09-03 08:54:26发表:
bank cheap loanbank cheap loan e fare per sblocre home bankinge fare per sblocre home banking payday loan canadapayday loan canada
195.225.177.* 于 2007-09-03 01:12:36发表:
orlando vacation rentalsorlando vacation rentals cheap vacationscheap vacations michigan vacation rentalmichigan vacation rental
195.225.177.* 于 2007-09-02 21:03:24发表:
beach vacation homesbeach vacation homes las vegas vacation home rentalslas vegas vacation home rentals santa monica vacationsanta monica vacation
195.225.177.* 于 2007-09-02 17:16:52发表:
orlando vacation rentalsorlando vacation rentals water filterswater filters wine theme weddingwine theme wedding
195.225.177.* 于 2007-09-02 11:01:40发表:
pet urine cleaning productspet urine cleaning products tax refundtax refund buy contact lenses online ortho kbuy contact lenses online ortho k
195.225.177.* 于 2007-09-02 06:17:10发表:
pet sittingpet sitting texas skin caretexas skin care best price panasonic plasma tvbest price panasonic plasma tv
210.42.140.* 于 2007-09-01 11:34:19发表:
wmjon wmjon
210.42.140.* 于 2007-09-01 11:34:15发表:
wmjon wmjon
195.225.177.* 于 2007-09-01 10:30:01发表:
Great sie url:http://www.linuxdiyf.com/viewarticle.php?id=28161(1214171319):)name:Medvedurl:http://google.comemail:none@none.commessage:Great sie
195.225.177.* 于 2007-09-01 06:30:53发表:
Great sie url:http://www.linuxdiyf.com/viewarticle.php?id=28161(1214171319):)name:Medvedurl:http://google.comemail:none@none.commessage:Great sie
195.225.177.* 于 2007-09-01 02:16:27发表:
Great sie url:http://www.linuxdiyf.com/viewarticle.php?id=28161(1214171319):)name:Medvedurl:http://google.comemail:none@none.commessage:Great sie
195.225.177.* 于 2007-08-31 21:57:25发表:
Great sie url:http://www.linuxdiyf.com/viewarticle.php?id=28161(1214171319):)name:Medvedurl:http://google.comemail:none@none.commessage:Great sie
195.225.177.* 于 2007-08-31 17:35:35发表:
Great sie url:http://www.linuxdiyf.com/viewarticle.php?id=28161(1214171319):)name:Medvedurl:http://google.comemail:none@none.commessage:Great sie
195.225.177.* 于 2007-08-31 05:31:35发表:
instructions for a 42 cup coffee makerinstructions for a 42 cup coffee maker discount concert ticketsdiscount concert tickets cheap air flights discount airline tickets flightscheap air flights discount airline tickets flights
195.225.177.* 于 2007-08-30 19:16:29发表:
cheap airline tickets discount airfares low web farescheap airline tickets discount airfares low web fares accounting career in coarbridgeaccounting career in coarbridge melitta travel coffee makermelitta travel coffee maker
195.101.183.* 于 2007-08-27 08:45:34发表:
new jersey
193.191.168.* 于 2007-08-27 03:07:08发表:
duplantis ministry
219.141.223.* 于 2007-08-27 01:44:22发表:
studio max
195.225.177.* 于 2007-08-26 08:26:43发表:
Great sie
192.72.124.* 于 2007-08-26 05:03:32发表:
chili recipie
81.88.210.* 于 2007-08-26 05:01:04发表:
pinhole camras
216.244.231.* 于 2007-08-25 01:35:14发表:
gibbon leeza
192.72.124.* 于 2007-08-25 00:07:45发表:
yuor dirty mind
125.46.36.* 于 2007-08-24 00:40:05发表:
simile peoms
219.87.178.* 于 2007-08-23 00:33:51发表:
blackpool casino evening gazzette super uk roulette online game casino barge handsonusa roulette online play roulette online gaming
125.46.36.* 于 2007-08-21 01:36:05发表:
cialis side effects cialis mail order yopza spyware windows servead spyware attori colore di porn
60.190.223.* 于 2007-08-20 01:37:32发表:
book buy com emilio guest online site xanax free generic sample viagra cheap tramadol controlled formulation hydrochloride release tramadol using very cheap tramadol
60.190.223.* 于 2007-08-19 01:38:06发表:
hot sex choot delhi sex inpop spyware porn video klipovi actress concealment in live married peep sex show truly
195.225.177.* 于 2007-08-18 20:20:20发表:
car online sellcar online sell hair transplant canadahair transplant canada alamo car rental nicealamo car rental nice
60.190.223.* 于 2007-08-18 01:49:50发表:
brodcast dssagent spyware sex haifa wahbe pic shesexy statbar spyware jandora sex game
89.208.84.* 于 2007-08-17 02:08:20发表:
porn somalian spyware isearch spyware stormer key crack geman porn fraction sexagesimal
202.96.189.* 于 2007-08-16 12:19:01发表:
adulti porn star toplist emailsystems mexico porn sidefind spyware clickspring spyware sexbrasil
89.208.84.* 于 2007-08-16 00:34:11发表:
videosection porn sexual buscosexo qsrch spyware en language language nl pornofilmpjes
56.0.84.* 于 2007-08-15 00:48:03发表:
sexy lady lyrics by nb ridaz netsetter spyware netropa nhk server spyware japanesexxx ie2bar spyware
60.190.223.* 于 2007-08-14 01:47:02发表:
spyware removal eyetide viewer spyware spysex angelica in magazine maxim panganiban picture sexy brasilien info remember sex
60.190.223.* 于 2007-08-13 04:01:59发表:
11 2006 from own site trackback viagra 0 add began by comment plog popl powered viagra free porn porn izle pornstory