Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I write the following simple script , the target of the following script is to copy info_file from target Linux (red hat 5.1) machine to my current Linux machine without entering login or password

I will happy to get some work examples with python that perform the same procedure as my expect script


  rm -rf /root/.ssh/known_hosts

  expect_get_info_file=`cat << EOF
  set timeout -1
  spawn  ssh
  expect ?                {send yes\r} 
  expect password:        {send pass123\r}
  expect #                {send "scp -rp /tmp\r"}
  expect password:        {send pass123\r}
  expect #                {send exit\r}
  expect eof

  expect -c  "$expect_get_info_file"
share|improve this question
Please don't. There are much easier and more secure ways of doing automatic SSH logins than that. – grawity Nov 16 '11 at 8:07
sorry I dont have expect tool to auto ssh , so the final option is python – diana Nov 17 '11 at 21:26
You just completely ignored what I said, didn't you. – grawity Nov 17 '11 at 22:03
no I am not , I know the ssh and public keys proccess , but I cant use this , sorry ( because some internal ishhues , ) , – diana Nov 18 '11 at 7:45
import pexpect
child = pexpect.spawn("ssh ....")
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.