无法使用SSH登录AWS EC2 ubuntu AMI

时间:2016-05-28 19:42:38

标签: ubuntu amazon-web-services ssh

我试图通过aws连接here提供的标准指南。

$chmod 400 key.pem
$ssh -i absolute_path_to_key/key.pem ubuntu@public_dns

引发错误

ssh: Could not resolve hostname public_dns: nodename nor servname provided, or not known

现在我尝试使用public_ip而不是public_dns, 再次,抛出错误

ssh: connect to host public_ip port 22: Connection refused

我检查了我的ubuntu服务器上的安全组,其入站是为所有IP地址启用了ssh并且正在侦听端口22.我尝试将key.pem内容复制到本地计算机上的.ssh / id_rsa文件。还没有成功。我认为我的本地机器ssh配置有问题。

本地机器:MacBook Air

任何建议/资源都表示赞赏。如果有人能指出我在ssh客户端配置上的资源,那也很棒。所以我可以仔细看看。三江源

****** ****** UPDATES

使用-vvv

后的输出
OpenSSH_6.9p1, LibreSSL 2.1.8
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 20: Applying options for *
debug1: /etc/ssh/ssh_config line 103: Applying options for *
ssh: Could not resolve hostname public_dns: nodename nor servname provided, or not known

这是我的ssh_config文件的样子:

#   $OpenBSD: ssh_config,v 1.26 2010/01/11 01:39:46 dtucker Exp $

# This is the ssh client system-wide configuration file.  See
# ssh_config(5) for more information.  This file provides defaults for
# users, and the values can be changed in per-user configuration files
# or on the command line.

# Configuration data is parsed as follows:
#  1. command line options
#  2. user-specific file
#  3. system-wide file
# Any configuration value is only changed the first time it is set.
# Thus, host-specific definitions should be at the beginning of the
# configuration file, and defaults at the end.

# Site-wide defaults for some commonly used options.  For a comprehensive
# list of available options, their meanings and defaults, please see the
# ssh_config(5) man page.

Host *
   SendEnv LANG LC_*

# Configuration options and default values (see ssh_config(5) for their meaning):
#
#   Host # (no default)
#   AddressFamily any
#   AskPassGUI yes # (Apple only)
#   BatchMode no
#   BindAddress # (no default)
#   ChallengeResponseAuthentication yes
#   CheckHostIP yes
#   Cipher 3des
#   Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour
#   ClearAllForwardings no
#   Compression no
#   CompressionLevel 6
#   ConnectionAttempts 1
#   ConnectTimeout # (no default)
#   ControlMaster no
#   ControlPath  # (no default)
#   ControlPersist no
#   DynamicForward
#   EnableSSHKeysign no
#   EscapeChar ~
#   ExitOnForwardFailure no
ForwardAgent yes
ForwardX11 yes
ForwardX11Timeout 1200
ForwardX11Trusted no
XauthLocation xauth
# Default is to search $PATH.  It is recommended that a full path be provided.
#   GatewayPorts no
#   GlobalKnownHostsFile /etc/ssh/ssh_known_hosts,/etc/ssh/ssh_known_hosts2
#   GSSAPIAuthentication no
#   GSSAPIDelegateCredentials no
#   GSSAPIKeyExchange no
#   GSSAPITrustDNS no
#   HashKnownHosts no
#   HostbasedAuthentication no
#   HostKeyAlgorithms ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ssh-dss-cert-v01@openssh.com,ssh-rsa-cert-v00@openssh.com,ssh-dss-cert-v00@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-rsa,ssh-dss
#   HostKeyAlias # (no default)
#   HostName # (set by command at run-time)
#   IdentitiesOnly no
#   IdentityFile .ssh/id_rsa,.ssh/id_dsa
#   IPQoS lowdelay
#   KbdInteractiveAuthentication yes
#   KbdInteractiveDevices # (no default)
#   KexAlgorithms ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
#   LocalCommand  # (no default)
#   LocalForward  # (no default)
#   LogLevel INFO
#   MACs hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-sha1-96,hmac-md5-96,hmac-sha2-256,hmac-sha2-256-96,hmac-sha2-512,hmac-sha2-512-96
#   NoHostAuthenticationForLocalhost no
#   NumberOfPasswordPrompts 3
#   PasswordAuthentication yes
#   PermitLocalCommand no
#   PKCS11Provider # (no default)
Port 22
#   PreferredAuthentications gssapi-with-mic,hostbased,publickey,keyboard-interactive,password  # (set by ssh at run-time)
#   Protocol 2
#   ProxyCommand # (no default)
#   PubkeyAuthentication yes
#   RekeyLimit 0
#   RemoteForward # (no default)
#   RequestTTY auto
#   RhostsRSAAuthentication no
#   RSAAuthentication yes
#   SendEnv # (no default)
#   ServerAliveCountMax 3
#   ServerAliveInterval 0
#   StrictHostKeyChecking ask
#   TCPKeepAlive yes
#   Tunnel no
#   TunnelDevice any:any
#   UsePrivilegedPort no
#   User # (set by command at run-time)
#   UserKnownHostsFile ~/.ssh/known_hosts,~/.ssh/known_hosts2
#   VerifyHostKeyDNS no
#   VisualHostKey no
#   XAuthLocationi xauth

# XAuthLocation added by XQuartz (http://xquartz.macosforge.org)
Host *
    XAuthLocation /opt/X11/bin/xauth

0 个答案:

没有答案