#!/usr/bin/expect set keyfile [lindex $argv 1] set certfile [lindex $argv 2] set timeout 2 spawn openssl req -x509 -nodes -days 1095 -newkey rsa:2048 -keyout "${keyfile}" -out "${certfile}" expect "Country Name (2 letter code) \[XX\]:" set timeout 1 send "US\r" expect "State or Province Name (full name) \[\]:" send "Some State\r" expect "Locality Name (eg, city) \[Default City\]:" send "Default City\r" expect "Organization Name (eg, company) \[Default Company Ltd\]:" send "Default Company Ltd\r" expect "Organizational Unit Name (eg, section) \[\]:" && send "Information Technologies\r" expect "Common Name (eg, your name or your server's hostname) \[\]:" send [lindex $argv 0] send "\r" expect "Email Address \[\]:" send "linuxadmin@example.com\r" interact