Newer
Older
Import / research / units / vm-pwless-login-setup.sh
@John John on 29 Dec 2020 575 bytes bulk import from macbookpro checkouts
#!/bin/bash

function setup_pwless_login
{
  cat > vm-pwless-login-setup.exp <<-EOF
    #!/usr/bin/expect
    set timeout 180
    set send_slow {1 .01}
    log_user 1
    eval spawn ssh-copy-id -f -p2222 "root\@localhost"
    expect  {
      timeout      { send_user "timeout\n"; exit }
      "*assword: " { send -s "root\r\r\r" }
    }
    wait
EOF
  echo "Please be patient while setting up automatic login to the VM."
  echo "This might take a bit of time..."
  expect -f ./vm-pwless-login-setup.exp
  echo "Done."
  rm ./vm-pwless-login-setup.exp
}

setup_pwless_login