I am discovering the bash scripting. I need to write a bash script to automatically connects my remote server with ssh. I am using MACOSX.
I were able to do with sudo as below
echo <root_pass> | sudo -S ls
However all my attempts were unsuccessful to pass the passphrase. I have tried these below already:
echo <my_passphrase> | sudo ssh -i /Users/path_to_ssh_public_key/ssh <my_username>@<remote_ip>
sudo ssh -i /Users/path_to_ssh_public_key/ssh <my_username>@<remote_ip> <<< echo <my_passphrase>
The command uses "-i" to get public key from a custom folder
Any help is welcome...
EDIT: I want to fully control the terminal outputs and inputs. I don't want to use sshpass or declare any variables to the shell.