Linux 不同服务器间传递文件 不需要输入密码

要求:把192.168.23.128机上的jenkins_web.war拷贝到10.12.1.1机器的上
第一步:192.168.23.128服务器上

mkdir -p ~/.ssh
chmod 700 ~/.ssh
ssh-keygen -t rsa -P "" -f ~/.ssh/id_rsa
在10.12.1.1建立好.ssh目录后,从192.168.23.128拷贝~/.ssh/id_rsa.pub到中~/.ssh目录下拷贝~/.ssh/id_rsa.pub到10.12.1.1中~/.ssh目录下建立好.ssh目录后,从192.168.23.128拷贝~/.ssh/id_rsa.pub到10.12.1.1中~/.ssh目录下
scp ~/.ssh/id_rsa.pub [email protected]:~/.ssh


[qagroup@redmine .ssh]$ more id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAspSHvd37Ouqx28W0P2ZIU7yTb+A5WRyVaT9I1nU9cNU9BBTs3QpgOG2kRdQcTrqlnXaR+eaWwYdPfwTbYsf40fwpdKtpfAMCmPwd8jBFE/grkJQfTC7hUYa4DpVZSu3/lW9
WDmtUQJVd4q2B4PCotEvW8kaN+A4St+5i3/0XlzBpaZbRrv/uZTB0OOrgFR4FcHJ+odFEhbw2k12KWQ1iixn3km1JpvxON/8cGmm27l2ZTcncET4dER7V1gbiRA9rgIwyxuT9BLeZGWPAdTOChg9JrV7wkEdxrCY0DeLrx9
vvSQJZfETjSL2V9txdX1Lj7q7KUpUvOdE22pobUxI0wQ== qagroup@redmine


第二步:10.12.1.1服务器上
mkdir -p ~/.ssh


[qagroup@redmine .ssh]$ more id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAspSHvd37Ouqx28W0P2ZIU7yTb+A5WRyVaT9I1nU9cNU9BBTs3QpgOG2kRdQcTrqlnXaR+eaWwYdPfwTbYsf40fwpdKtpfAMCmPwd8jBFE/grkJQfTC7hUYa4DpVZSu3/lW9
WDmtUQJVd4q2B4PCotEvW8kaN+A4St+5i3/0XlzBpaZbRrv/uZTB0OOrgFR4FcHJ+odFEhbw2k12KWQ1iixn3km1JpvxON/8cGmm27l2ZTcncET4dER7V1gbiRA9rgIwyxuT9BLeZGWPAdTOChg9JrV7wkEdxrCY0DeLrx9
vvSQJZfETjSL2V9txdX1Lj7q7KUpUvOdE22pobUxI0wQ== qagroup@redmine


[qagroup@redmine .ssh]$ more authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAspSHvd37Ouqx28W0P2ZIU7yTb+A5WRyVaT9I1nU9cNU9BBTs3QpgOG2kRdQcTrqlnXaR+eaWwYdPfwTbYsf40fwpdKtpfAMCmPwd8jBFE/grkJQfTC7hUYa4DpVZSu3/lW9
WDmtUQJVd4q2B4PCotEvW8kaN+A4St+5i3/0XlzBpaZbRrv/uZTB0OOrgFR4FcHJ+odFEhbw2k12KWQ1iixn3km1JpvxON/8cGmm27l2ZTcncET4dER7V1gbiRA9rgIwyxuT9BLeZGWPAdTOChg9JrV7wkEdxrCY0DeLrx9
vvSQJZfETjSL2V9txdX1Lj7q7KUpUvOdE22pobUxI0wQ== qagroup@redmine


第三步:把从192.168.23.128拷贝过来的id_rsa.pub重命名为authorized_keys
cp id_rsa.pub authorized_keys
chmod 600 ~/.ssh/authorized_keys

第四步: 验证scp传递

[qagroup@redmine target]$ scp jenkins_web.war  [email protected]:/home/qagroup/tmp/jenkins_web.war
Address 10.12.1.1 maps to localhost, but this does not map back to the address - POSSIBLE BREAK-IN ATTEMPT!
jenkins_web.war






你可能感兴趣的:(工作点滴那些事)