1

I am facing an issue when I run simply these commands.

The remote server want to pass "yes" to add the key in RSA file because first time connection established with scp.

commands are given below

#!/bin/bash

scp  -P58222 root@IP:/root/K /N
/usr/bin/expect -c 'expect "\n" { expect "Are you sure you want to continue connecting (yes/no)?" }'
send "yes\r"
expect "$ "
send "exit\r"

Actually I have to pass yes in my script while showing

Are you sure you want to continue connecting (yes/no)?

how can i get rid of this problem..?

2 Answers 2

1

Instead of scripting the response with expect, just turn off prompting before adding.

scp -o "StrictHostKeyChecking no" ...

Since you're using expect with ssh in the first place, I'll just say that ssh-copy-id to set up passwordless ssh is a much better way to do things.

1

Here is fragment from my working script.

  send_user "FILE \"FILETEMPL\" is copied to active.\n"  
  spawn scp -l 60 FILETEMPL root@IP:PATHTEMPL/FILETEMPL  
  # After scp we should wait "#" or "100%".  
  set timeout 600  
  expect {  
    "password: " {   
      send "PASS\r"   
        expect {  
          "100% "         {...}  
          "password: " { .. }  
          timeout      { ... }  
      }   
    }  
    timeout      { exit 1 }  
    eof          { exit 2 }  
  }   

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .