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

后端 未结 9 713
礼貌的吻别
礼貌的吻别 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:30

    I was recently asked to switch over from ftp to sftp, in order to secure the file transmission between servers. We are using Tectia SSH package, which has an option --password to pass the password on the command line.

    example : sftp --password="password" "userid"@"servername"

    Batch example :

    (
      echo "
      ascii
      cd pub
      lcd dir_name
      put filename
      close
      quit
        "
    ) | sftp --password="password" "userid"@"servername"
    

    I thought I should share this information, since I was looking at various websites, before running the help command (sftp -h), and was i surprised to see the password option.

提交回复
热议问题