Issue
I am trying to write a bash script to make things faster. Is it not possible to connect to the server with the code below in a bash script? I can't make it work, even though it works in the terminal.
#!/bin/bash -x
echo "Starting connection script"
sh -i /home/EC2_KEY_HEHE.pem [email protected]
What I get when I run is a not found output for each line in the pem file,
$ /home/EC2_KEY_HEHE.pem: 1: /home/EC2_KEY_HEHE.pem: -----BEGIN: not found
$ /home/EC2_KEY_HEHE.pem: 1: /home/EC2_KEY_HEHE.pem: adsnaleAFemasdsdsdnds: not foundMadfdasfdasfnda;vonraada
...
Solution
Some debug is needed.
Please change:
ssh -i /home/EC2_KEY_HEHE.pem [email protected]
to:
#!/bin/bash -x
echo "Starting connection script"
ssh -vi /home/EC2_KEY_HEHE.pem [email protected]
does it produce an idea about the reason ?
Answered By - Kirill Chernyavskiy Answer Checked By - Mary Flores (WPSolving Volunteer)