本文共 5628 字,大约阅读时间需要 18 分钟。
[TOC]
分布式应用通常要发布到非常多的机器,需要保持每台一致性,减轻工作量。可使用scp命令。
ssh-keygen,直接回车,不用输入。
[webuser@pay-app-sever3 ~]$ ssh-keygenGenerating 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-sever3The 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 ~]$
[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-clientsLoaded plugins: fastestmirrorRepodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fastYou need to be root to perform this command.
解决:
yum -y install openssh-clients用root执行这个[root@pay-app-sever3 ~]# yum -y install openssh-clientLoaded plugins: fastestmirrorRepodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fastbase | 3.6 kB 00:00:00 Determining fastest mirrorsNo package openssh-client available.Error: Nothing to do[root@pay-app-sever3 ~]#
?[root@pay-app-sever3 ~]# yum -y install openssh-clientsLoaded plugins: fastestmirrorLoading mirror speeds from cached hostfileResolving 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 ResolutionDependencies Resolved============================================================================================================================================ Package Arch Version Repository Size============================================================================================================================================Installing: openssh-clients x86_64 6.6.1p1-22.el7 base 639 kInstalling for dependencies: openssh x86_64 6.6.1p1-22.el7 base 434 kTransaction Summary============================================================================================================================================Install 1 Package (+1 Dependent package)Total download size: 1.0 MInstalled size: 3.6 MDownloading packages:--------------------------------------------------------------------------------------------------------------------------------------------Total 10 MB/s | 1.0 MB 00:00:00 Running transaction checkRunning transaction testTransaction test succeededRunning transactionWarning: 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 ~]#
输入yes
输入密码[webuser@pay-app-sever3 ~]$ ssh-copy-id pay-app-sever4The 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: 1Now 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 -r /app/Server/classes webuser@21.13.22.107:/app/Server/
转载于:https://blog.51cto.com/170023/2151683