I am experiencing something strange. I am working on a script to remote install Splunk on servers via a script. In this script I ssh to my practice servers (5 amazon EC2 instances running Redhat).
However, when I run the script I get this error:
Warning: Identity file ~/Keypairs/jadam-macbookpro-ec2-1.pem not accessible: No such file or directory.
My first step was to obviously make sure that the path was there. I copy the command run and paste it into my terminal. I successfully connect to my instance using the keypair.
Here is the command in question. I have tried it both with and without sudo prefixing the command:
KEYPAIR="~/Keypairs/jadam-macbookpro-ec2-1.pem" sudo ssh -i "$KEYPAIR" "$DST" "$REMOTE_SCRIPT"
REMOTE_SCRIPT is the script file to run, and DST is my server addresses pulled from a hosts file.
The resolved command is:
ssh -i ~/Keypairs/jadam-macbookpro-ec2-1.pem firstname.lastname@example.org
The script fails, but copying the command and doing it manually works. I thought it was a permissions issue at first, which is why I ran it with sudo, but it thinks the directory doesn't exist.