how to pass password for rsync ssh command

2019-01-16 03:46发布

I need to do rsync by ssh and want to do it automatically without need of passing password for ssh manually.

12条回答
孤傲高冷的网名
2楼-- · 2019-01-16 04:01

I use a VBScript file for doing this on Windows platform, it servers me very well.

set shell = CreateObject("WScript.Shell")
shell.run"rsync -a Name@192.168.1.100:/Users/Name/Projects/test ."
WScript.Sleep 100
shell.SendKeys"Your_Password"
shell.SendKeys "{ENTER}"
查看更多
混吃等死
3楼-- · 2019-01-16 04:05

You should use a keyfile without passphrase for scripted ssh logins. This is obviously a security risk, take care that the keyfile itself is adequately secured.

Instructions for setting up passwordless ssh access

查看更多
Viruses.
4楼-- · 2019-01-16 04:07

Though you've already implemented it by now,

you can also use any expect implementation (you'll find alternatives in Perl, Python: pexpect, paramiko, etc..)

查看更多
迷人小祖宗
5楼-- · 2019-01-16 04:14

I work out so

sshpass -p "password" rsync -ae "ssh -p remote_port_ssh" /local_dir remote_user@remote_host:/remote_dir

查看更多
唯我独甜
6楼-- · 2019-01-16 04:15

use a ssh key :

look at ssh-keygen and ssh-copy-id.

After that you can use an rsync this way :

rsync -a --stats --progress --delete /home/path server:path
查看更多
7楼-- · 2019-01-16 04:15

the following works for me

SSHPASS='myPassword'
/usr/bin/rsync -a -r -p -o -g --progress --modify-window=1 --exclude /folderOne -s -u --rsh="/usr/bin/sshpass -p $SSHPASS ssh -o StrictHostKeyChecking=no -l root"  source-path  myDomain:dest-path  >&2

I had to install sshpass

查看更多
登录 后发表回答