多台客户端机器通过scp命令远程拷贝文件到一台服务器
多台客户端机器为ip为
192.168.18.2 B
192.168.18.3 C
192.168.18.4 D
服务器
192.168.18.1 A
客户端配置
1.在客户端:192.168.18.2生成ssh-keygen
192.196.18.2上
# ssh-keygen -b 1024 -t rsa
全部回车不用输入任何字符,会在/root/.ssh/目录下生成一个id_rsa.pub的文件
# cd /root/.ssh
# ls -ld *
赋给id_rsa.pub文件执行权限
# chmod 755 /root/.ssh/id_rsa.pub
将192.168.18.2客户端生成的id_rsa.pub上传到192.168.18.1服务器上,并生成文件authorized_keys_B
# scp -p /root/.ssh/id_rsa.pub 192.168.18.1:/root/.ssh/authorized_keys_B
这时会提示是否上传和输入密码。输入y,然后输入服务器端的密码即可
password:
2.在客户端:192.168.18.3生成ssh-keygen
192.196.18.3上
# ssh-keygen -b 1024 -t rsa
全部回车不用输入任何字符,会在/root/.ssh/目录下生成一个id_rsa.pub的文件
# cd /root/.ssh
# ls -ld *
赋给id_rsa.pub文件执行权限
# chmod 755 /root/.ssh/id_rsa.pub
将192.168.18.3客户端生成的id_rsa.pub上传到192.168.18.1服务器上,并生成文件authorized_keys_C
# scp -p /root/.ssh/id_rsa.pub 192.168.18.1:/root/.ssh/authorized_keys_C
这时会提示是否上传和输入密码。输入y,然后输入服务器端的密码即可
password:
3.在客户端:192.168.18.4生成ssh-keygen
192.196.18.4上
# ssh-keygen -b 1024 -t rsa
全部回车不用输入任何字符,会在/root/.ssh/目录下生成一个id_rsa.pub的文件
# cd /root/.ssh
# ls -ld *
赋给id_rsa.pub文件执行权限
# chmod 755 /root/.ssh/id_rsa.pub
将192.168.18.4客户端生成的id_rsa.pub上传到192.168.18.1服务器上,并生成文件authorized_keys_D
# scp -p /root/.ssh/id_rsa.pub 192.168.18.1:/root/.ssh/authorized_keys_D
这时会提示是否上传和输入密码。输入y,然后输入服务器端的密码即可
password:
服务器端配置
1.登录服务器192.168.18.1
# cd /root/.ssh/
# ls -ld *
会看到有
authorized_keys_B authorized_keys_C authorized_keys_D
这几个文件
# cat authorized_keys_B >> authorized_keys_C >> authorized_keys_D >> authorized_keys
将authorized_keys_B、authorized_keys_C和authorized_keys_D的文件内容添加到authorized_keys文件中
# chmod 755 /root/.ssh/authorized_keys
添加可执行权限
以上配置成功后,客户端在使用scp命令上传文档至服务器端时,可以不输入密码进行传输