Skip to main content
Minor grammatical clarification
Source Link
Chris Davies
  • 128.2k
  • 16
  • 179
  • 324

Actually your resolved command isn't right. It's really this:

ssh -i "~/Keypairs/jadam-macbookpro-ec2-1.pem" "[email protected]"

The double quotes stop the shell expanding ~ and it's treated there as a literal (passed directly on to ssh). Replace it with the environment variable $HOME and the problem will resolve itself:

KEYPAIR="$HOME/Keypairs/jadam-macbookpro-ec2-1.pem"
sudo ssh -i "$KEYPAIR" "$DST" "$REMOTE_SCRIPT"

I should point out that ssh will evaluate the ~ as home directory, but in this case it will be doing so in root's context rather than yours, so will not be looking for the file in your $HOME/.ssh directory.

Actually your resolved command isn't right. It's really this:

ssh -i "~/Keypairs/jadam-macbookpro-ec2-1.pem" "[email protected]"

The double quotes stop the shell expanding ~ and it's treated as a literal. Replace it with the environment variable $HOME and the problem will resolve itself:

KEYPAIR="$HOME/Keypairs/jadam-macbookpro-ec2-1.pem"
sudo ssh -i "$KEYPAIR" "$DST" "$REMOTE_SCRIPT"

I should point out that ssh will evaluate the ~ as home directory, but in this case it will be doing so in root's context rather than yours, so will not be looking for the file in your $HOME/.ssh directory.

Actually your resolved command isn't right. It's really this:

ssh -i "~/Keypairs/jadam-macbookpro-ec2-1.pem" "[email protected]"

The double quotes stop the shell expanding ~ and it's treated there as a literal (passed directly on to ssh). Replace it with the environment variable $HOME and the problem will resolve itself:

KEYPAIR="$HOME/Keypairs/jadam-macbookpro-ec2-1.pem"
sudo ssh -i "$KEYPAIR" "$DST" "$REMOTE_SCRIPT"

I should point out that ssh will evaluate the ~ as home directory, but in this case it will be doing so in root's context rather than yours, so will not be looking for the file in your $HOME/.ssh directory.

Clarified that ~ is handled specially by ssh
Source Link
Chris Davies
  • 128.2k
  • 16
  • 179
  • 324

Actually your resolved command isn't right. It's really this:

ssh -i "~/Keypairs/jadam-macbookpro-ec2-1.pem" "[email protected]"

The double quotes stop the shell expanding ~ and it's treated as a literal. Replace it with the environment variable $HOME and the problem will resolve itself:

KEYPAIR="$HOME/Keypairs/jadam-macbookpro-ec2-1.pem"
sudo ssh -i "$KEYPAIR" "$DST" "$REMOTE_SCRIPT"

I should point out that ssh will evaluate the ~ as home directory, but in this case it will be doing so in root's context rather than yours, so will not be looking for the file in your $HOME/.ssh directory.

Actually your resolved command isn't right. It's really this:

ssh -i "~/Keypairs/jadam-macbookpro-ec2-1.pem" "[email protected]"

The double quotes stop the shell expanding ~ and it's treated as a literal. Replace it with the environment variable $HOME and the problem will resolve itself:

KEYPAIR="$HOME/Keypairs/jadam-macbookpro-ec2-1.pem"
sudo ssh -i "$KEYPAIR" "$DST" "$REMOTE_SCRIPT"

Actually your resolved command isn't right. It's really this:

ssh -i "~/Keypairs/jadam-macbookpro-ec2-1.pem" "[email protected]"

The double quotes stop the shell expanding ~ and it's treated as a literal. Replace it with the environment variable $HOME and the problem will resolve itself:

KEYPAIR="$HOME/Keypairs/jadam-macbookpro-ec2-1.pem"
sudo ssh -i "$KEYPAIR" "$DST" "$REMOTE_SCRIPT"

I should point out that ssh will evaluate the ~ as home directory, but in this case it will be doing so in root's context rather than yours, so will not be looking for the file in your $HOME/.ssh directory.

Source Link
Chris Davies
  • 128.2k
  • 16
  • 179
  • 324

Actually your resolved command isn't right. It's really this:

ssh -i "~/Keypairs/jadam-macbookpro-ec2-1.pem" "[email protected]"

The double quotes stop the shell expanding ~ and it's treated as a literal. Replace it with the environment variable $HOME and the problem will resolve itself:

KEYPAIR="$HOME/Keypairs/jadam-macbookpro-ec2-1.pem"
sudo ssh -i "$KEYPAIR" "$DST" "$REMOTE_SCRIPT"