Shell 将文件从一台服务器复制到另一台服务器的脚本

Shell Script to Copy file from one server to another

我有 2 个 solaris 服务器。我想编写一个 shell 脚本,它将文件从一台服务器复制到另一台服务器。

scp /tmp/test/a.war tomcat@202.203.204.44:/tmp/

在 PUTTY 中执行上述命令时,会要求我输入目标密码。这在使用 PUTTY 时很好。

如何通过shell脚本在运行执行scp命令时输入密码?

提前致谢

您必须设置 SSH private/public 密钥。

生成后将 public 键行条目放在目标服务器和用户的 ~/.ssh/authorized_keys 文件中。

确保源计算机上的文件(对于将 运行 scp/ssh 命令的用户)具有建议的文件权限 (400)。

https://unix.stackexchange.com/questions/182483/scp-without-password-prompt-using-different-username

http://docs.oracle.com/cd/E19253-01/816-4557/sshuser-33/index.html 或类似的联机帮助可以帮助您。