How to run the sftp command with a password from Bash script?

后端 未结 9 716
礼貌的吻别
礼貌的吻别 2020-11-22 11:55

I need to transfer a log file to a remote host using sftp from a Linux host. I have been provided credentials for the same from my operations group. However, since I don\'t

9条回答
  •  独厮守ぢ
    2020-11-22 12:42

    You can use sshpass for it. Below are the steps

    1. Install sshpass For Ubuntu - sudo apt-get install sshpass
    2. Add the Remote IP to your known-host file if it is first time For Ubuntu -> ssh user@IP -> enter 'yes'
    3. give a combined command of scp and sshpass for it. Below is a sample code for war coping to remote tomcat sshpass -p '#Password_For_remote_machine' scp /home/ubuntu/latest_build/abc.war #user@#RemoteIP:/var/lib/tomcat7/webapps

提交回复
热议问题