I'm learning "startup engineering", encountered this error when using ssh alias. Below is the detailed steps (executed in Cygwin windows 8):
$ mkdir -p ~/.ssh
$ cp ~/downloads/skey.pem ~/.ssh/
$ chmod 400 ~/.ssh/skey.pem
$ chmod 700 ~/.ssh
$ nano ~/.ssh/config
$ cat ~/.ssh/config
Host awshost1
HostName ec2-54-218-35-71.us-west-2.compute.amazonaws.com
User ubuntu
IdentityFile "~/.ssh/skey.pem"
Then I ran below command
ssh awshost1
But it prompts
ssh: Could not resolve hostname awshost1: hostname nor servname provided, or not known
And the verbose output:
$ ssh -vv awshost
OpenSSH_6.2p2, OpenSSL 1.0.1e 11 Feb 2013
debug1: Reading configuration data /etc/ssh_config
debug2: ssh_connect: needpriv 0
ssh: Could not resolve hostname awshost: hostname nor servname provided, or not known
Would anyone please help me on this? Thanks.
Best Answer
As you can see from the output, your ssh-client reads
/etc/ssh_config
, not~/.ssh/config
. Try to connect like that:ssh -F ~/.ssh/config awshost1
.