pass password to sftp in a bash script

混江龙づ霸主 提交于 2019-12-08 05:11:27

With scp/sftp you should use key-based authentication. Public key from the user you want to authenticate copy into ~/.ssh/authorized_keys file on the server, into home directory of user on which you want log on. Storing password in clear text on client side is not a good practice, you know :) That way you "workaround" problem of reading password from the prompt too.

cmdilip

Please try the below steps

lftp -u $user,$pass sftp://$host << --EOF--
cd $directory
put $srcfile
quit
--EOF--

Yes key-based auth is the way to go. Check here for some direction.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!