Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

310
Views
Automate SFTP/SSH prompts on Linux

I'm particularly new to shell scripting and ssh commands and such. I was wondering if I could automate simple sftp prompts when uploading/downloading files from one server to another.

Here is what I do:

  • command: sftp username@ServerHost
  • Response: The authenticity of host '***' can't be established. Are you sure you want to continue connecting (yes/no)?
  • after I type 'yes' it asks me the password

I essentially want to automate this since I'll be calling a script which will upload a file from my source server to a remote one through an InfoSphere Datastage sequence job on the source server.

PS. Pardon my insolence if this question doesn't make sense of if it's too juvenile :)

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

check out expect, that helps to automate such issues in scripts.

Here a sample that works for me:

#!/usr/bin/expect -f

set timeout 30

set user "coder"
set node "repohost"
set fsrc "/home/coder/Sources/sysperf/makefile"
set fdst "/tmp"
set uspw "topSecret"

spawn sftp $user@$node:$fsrc $fdst
expect_after eof {exit 1}
expect "$user@$node's password: " {send "$uspw\r"}
expect "*100%*" 
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!