0
#!/bin/bash

echo "Connecting to the vm..."
ssh -t root@${host} ${command}

This is a shell script to send commands to a remote machine via ssh, It is giving password prompt. But there is no need to enter password and only enter key press is required. How to pass enter key press to this ssh command when prompted

Tried to send 'Enter' key using the following methods, But it is not working

echo -ne '\n' | ssh -t -t root@${host} ${command}
cat <(echo "") | ssh -t -t root@${host} ${command}
yes '' | ssh -t -t root@${host} ${command}
Abhi
  • 319
  • 1
  • 5
  • 19
  • Why is enter key press required? – wowbagger Oct 29 '21 at 13:25
  • When prompted for password, only enter key press is required for ssh to this particular remote machine – Abhi Oct 29 '21 at 13:53
  • It sounds like the server is insisting on performing some kind of password authentication, even if it accepts a blank password. See https://stackoverflow.com/a/43526842/13317 – Kenster Oct 29 '21 at 14:28
  • 1
    `echo -ne '\n'` is just a long, non-standard way to write `echo`. – chepner Oct 29 '21 at 14:51
  • Is it `ssh` asking for the password, or the remote command? `ssh` doesn't read passwords from standard input by default, but directly from the terminal. – chepner Oct 29 '21 at 14:52
  • Even if the password is the empty string, you should still use public-key authentication for automated logins. – chepner Oct 29 '21 at 14:53

0 Answers0