通过scp一键把应用发布到多台机器

[TOC]

前言

分布式应用通常要发布到非常多的机器,需要保持每台一致性,减轻工作量。可使用scp命令。

ssh-keygen

ssh-keygen,直接回车,不用输入。

[webuser@pay-app-sever3 ~]$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/app/webuser/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /app/webuser/.ssh/id_rsa.
Your public key has been saved in /app/webuser/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:MaSY8MmHYA+vWQw7wZFz464hiG+W8V0HvlbtLKyUXbI webuser@pay-app-sever3
The key's randomart image is:
+---[RSA 2048]----+
| .Oo    .        |
| .+&o= o         |
|  o+%.o o        |
|   =..  .o       |
|o o.   .S....    |
|+ o .   ooo+.    |
| o * . .o=Eo     |
|  * . ..o o o    |
| o     ... .     |
+----[SHA256]-----+
[webuser@pay-app-sever3 ~]$ 

yum -y install openssh-clients

[webuser@pay-app-sever3 ~]$ ssh-copy-id  pay-app-sever4
-bash: ssh-copy-id: command not found
[webuser@pay-app-sever3 ~]$ yum -y install openssh-clients
Loaded plugins: fastestmirror
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
You need to be root to perform this command.

解决:
yum -y install openssh-clients用root执行这个

小插曲:漏了s

    [root@pay-app-sever3 ~]# yum -y install openssh-client
Loaded plugins: fastestmirror
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
base                                                                                                                 | 3.6 kB  00:00:00     
Determining fastest mirrors
No package openssh-client available.
Error: Nothing to do
[root@pay-app-sever3 ~]# 

执行成功

?[root@pay-app-sever3 ~]# yum -y install openssh-clients
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package openssh-clients.x86_64 0:6.6.1p1-22.el7 will be installed
--> Processing Dependency: openssh = 6.6.1p1-22.el7 for package: openssh-clients-6.6.1p1-22.el7.x86_64
--> Running transaction check
---> Package openssh.x86_64 0:6.6.1p1-22.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

============================================================================================================================================
 Package                               Arch                         Version                                Repository                  Size
============================================================================================================================================
Installing:
 openssh-clients                       x86_64                       6.6.1p1-22.el7                         base                       639 k
Installing for dependencies:
 openssh                               x86_64                       6.6.1p1-22.el7                         base                       434 k

Transaction Summary
============================================================================================================================================
Install  1 Package (+1 Dependent package)

Total download size: 1.0 M
Installed size: 3.6 M
Downloading packages:
--------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                        10 MB/s | 1.0 MB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
** Found 1 pre-existing rpmdb problem(s), 'yum check' output follows:
git-1.8.3.1-5.el7.x86_64 has missing requires of openssh-clients
  Installing : openssh-6.6.1p1-22.el7.x86_64                                                                                            1/2 
warning: /etc/ssh/moduli created as /etc/ssh/moduli.rpmnew
  Installing : openssh-clients-6.6.1p1-22.el7.x86_64                                                                                    2/2 
warning: /etc/ssh/ssh_config created as /etc/ssh/ssh_config.rpmnew
  Verifying  : openssh-clients-6.6.1p1-22.el7.x86_64                                                                                    1/2 
  Verifying  : openssh-6.6.1p1-22.el7.x86_64                                                                                            2/2 

Installed:
  openssh-clients.x86_64 0:6.6.1p1-22.el7                                                                                                   

Dependency Installed:
  openssh.x86_64 0:6.6.1p1-22.el7                                                                                                           

Complete!
[root@pay-app-sever3 ~]# 

ssh-copy-id

输入yes
输入密码

[webuser@pay-app-sever3 ~]$ ssh-copy-id  pay-app-sever4
The authenticity of host 'pay-app-sever4 (21.13.22.107)' can't be established.
ECDSA key fingerprint is c4:c0:12:67:9f:9b:d8:b1:5e:c9:85:15:88:b3:a1:02.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
 Authorized only. All activity will be monitored and reported 
webuser@pay-app-sever4's password: 
Permission denied, please try again.
webuser@pay-app-sever4's password: 

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'pay-app-sever4'"
and check to make sure that only the key(s) you wanted were added.

[webuser@pay-app-sever3 ~]$ 

scp

scp -r /app/Server/classes webuser@21.13.22.107:/app/Server/

转载于:https://blog.51cto.com/170023/2151683

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值