远程linux
指令:scp local_file remote_username@remote_ip:remote_folder
linux本地<-----远程linux
指令:scp remote_username@remote_ip:remote_folder local_file
具体详细连接:http://www.cnblogs.com/hitwtx/archive/2011/11/16/2251254.html
这里详细说说如何实现多台设备传输
实现步骤:
1)写xshell脚本的一个expect 插件实现一台设备的传输编程输入密码
exp.sh
#!/usr/bin/expect -f
set timeout 10
set username [lindex $argv 0]
set password [lindex $argv 1]
set hostname [lindex $argv 2]
spawn scp $username@$hostname
expect "yes/no"
send "yes\r"
expect "password:"
send "$password\r"
expect eof
测试:./exp.sh root pasword hostname1
#expect接收参数的方式和bash脚本的方式不太一样,bash是通过$0 ... $n 这种方式,而expect是通过set <变量名称> [lindex $argv ],例如set username [lindex $argv 0]
2)写一个循环调用脚本
#!/bin/ksh
#定义一个远程主机ip数组,也可以通过文件查询方式
remoteips=‘10.71.148.15 10.71.148.23‘
uesrname=root
passwd= pwd
for ip in $remoteips
do
./exp.sh $uesrname $pwd $ip
done
执行前确保文件可执行
>chmod +x XX.shlinux 多台远程设备传递文件
原文:http://www.cnblogs.com/niusir/p/5551611.html