设有两机,均为局域网,两机可相互通信无问题,中间无防火墙。

两机IP分别为:A:192.168.1.240 B:192.168.1.102

假设A,B机的SSH都允许root登录

设要把 A上的 /root/abc.zip 传到 B机并放到/abc目录,可以在A机上用命令

    scp  /root/abc.zip  ​​root@192.168.1.102:/abc/​

若 SSH端口不是默认的22,比如,是端口1234 则加-P参数:

    scp  -P 1234 /root/abc.zip  ​​root@192.168.1.102:/abc/​

也可以在B机上用命令:

    scp  ​​root@192.168.1.240:/root/abc.zip​​  /abc/

下面给出一个例子,希望你看得懂:

 

代码

[root@localhost ~]# pwd

/root

[root@localhost ~]# ls

anaconda-ks.cfg ftpaccount install.log.syslog

backup.tar.gz install.log svn1.4.3

[root@localhost ~]# scp backup.tar.gz root@192.168.1.21:/tmp/

The authenticity of host '192.168.1.21 (192.168.1.21)' can't be established.

RSA key fingerprint is 4d:b4:e1:5b:80:8f:ea:df:0a:eb:dd:30:e7:00:07:90.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added '192.168.1.21' (RSA) to the list of known hosts.

root@192.168.1.21's password: << 提示输入192.168.1.21的SSH密码

backup.tar.gz 100% 5120KB 1.3MB/s 00:04

[root@localhost ~]#