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
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