Expect script issue

后端 未结 2 1198
伪装坚强ぢ
伪装坚强ぢ 2021-01-19 13:16

I am trying to accomplish a simple job via expect. I want to create ssh keys using the \"ssh-keygen\" command on Linux VMs. My below expect code looks to be straight forward

2条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-19 14:03

    I suppose you're exiting to quickly. This one works for me:

    #!/usr/bin/expect
    
    spawn ssh-keygen -t rsa
    expect "Enter file in which to save the key (/root/.ssh/id_rsa): "
    send  "\r"
    expect "Enter passphrase (empty for no passphrase): "
    send  "\r"
    expect "Enter same passphrase again: "
    send  "\r"
    expect
    

提交回复
热议问题