使用ssh在本地服务器和远程服务器之间传输文件,无需密码验

时间:2016-03-02 10:24:06

标签: linux macos authentication ssh

我想将一些文件从我的本地转移到远程,就像github那样。我希望它像shell脚本一样非常流畅。我尝试创建一个shell脚本,它可以自动执行ssh身份验证过程而无需密码,但是第一次暴露了我的远程服务器密码。我不想这样做。就像在git中我们看不到他们的服务器密码。我们有什么办法吗?

我使用这篇文章脚本来自动执行ssh登录。 http://www.techpaste.com/2013/04/shell-script-automate-ssh-key-transfer-hosts-linux/

1 个答案:

答案 0 :(得分:0)

As i mentioned, you can use the scp command, like this:

scp /local_dir/some*.xml remote_user@remote_machine:/var/www/html

This requires that you need connect to the remote machine without password, only with ssh key-authentication.

Here is a link: http://linuxproblem.org/art_9.html to help you.

The important steps: (automatic login from host A / user a to Host B / user b.)

a@A:~> ssh-keygen -t rsa
a@A:~> ssh b@B mkdir -p .ssh
a@A:~> cat .ssh/id_rsa.pub | ssh b@B 'cat >> .ssh/authorized_keys'