尝试访问EC2实例时超时的可能原因

时间:2010-05-11 19:30:21

标签: ssh amazon-ec2 amazon-web-services

我无法通过SSH连接到我的实例 - 操作超时。可能是什么原因,我该怎么做才能解决它?重新启动通常需要很长时间才能生效,并且可能会使事情变得更糟

更新:这不是关于权限 - 我可以正常登录就好了。我怀疑这可能是因为内存问题

27 个答案:

答案 0 :(得分:83)

我遇到了同样的问题,最终解决方案是添加我的问题 本地计算机的IP到活动安全性中的入站规则列表 组。在下面的入站对话框中,在端口范围中输入22,在源字段中输入local IP / 32,并在下拉列表中保留“custom tcp rule”。

enter image description here

答案 1 :(得分:63)

您是否为该实例设置了适当的安全组?即允许从您的网络访问实例上的端口22的一个。 (默认情况下,不允许所有流量。)

更新:好的,不是安全组问题。但是,如果您从同一个AMI启动另一个实例并尝试访问它,问题是否仍然存在?也许这个特定的EC2实例只是随机地以某种方式失败了 - 只是时间问题才会发生。 (推荐阅读:Architecting for the Cloud: Best Practices(PDF),Jinesh Varia的论文,他是亚马逊的网络服务传播者。特别参见标题为“设计失败,没有任何事情会失败”的部分。)

答案 2 :(得分:25)

摧毁并重新创建

我有一个可用区域,我可以连接,另一个我无法连接。几个小时后,我非常沮丧,因此我删除了可用区中的所有内容。

重建一切我必须确保创造一切。其中包括:

  • 创建 VPC
    • CIDR: 10.0.0.0/24
  • 创建 Internet网关
  • Internet网关附加到 VPC
  • 创建路由表
  • 路由添加到路由表
    • Destination: 0.0.0.0/0
    • Target: <Internet Gateway from earlier>
  • 创建子网
    • CIDR: 10.0.0.0/24
    • Routing Table: <Routing Table from earlier

我花了很多时间来摸索所有这一切。我已经按照我认为最有效的方式订购了这些步骤,但您可能需要对其进行调整以使下一个项目可用。

建议

我并没有像你那样建议你去热核。我提供了所有这些信息,以便您可以检查这些关联以确保您的信息合适。

答案 3 :(得分:19)

这个答案适合愚蠢的人(像我一样)。您的EC2的公共DNS可能(将)在重新启动时更改。如果您没有意识到这一点并尝试通过SSH连接到旧的公共DNS,则连接将停止并超时。这可能会导致您假设您的EC2或安全组出现问题或者......不,只需通过SSH连接到新的DNS。如果必须,请更新您的~/.ssh/config文件!

答案 4 :(得分:11)

连接使用ssh如下:

ssh -i keyname.pem username@xxx.xx.xxx.xx

其中keyname.pem是您的私钥的名称,username是您的os分发的正确用户名,xxx.xx.xxx.xx是公共IP地址。

超时或失败时,请检查以下内容:

安全小组

确保 tcp端口22 的入站规则以及所有ips或您的IP。您可以通过实例选项中的ec2菜单找到安全组。

路由表

对于vpc中的新子网,您需要更改为将 0.0.0.0/0指向Internet网关目标的路由表。在vpc中创建子网时,默认情况下会分配默认路由表,该表可能不接受来自Internet的传入流量。您可以在vpc菜单中编辑路由表选项,然后编辑子网。

弹性IP

对于vpc中的实例,您需要分配公共弹性IP地址,并将其与实例关联。私人IP地址无法从外部访问。您可以在ec2菜单中获得弹性IP(不是实例菜单)。

用户名

确保您使用正确的用户名。它应该是ec2-userrootubuntu中的一个。如有必要,请尝试所有。

私钥

确保您使用正确的私钥(您下载或启动实例时选择的那个)。看起来很明显,但复制粘贴让我两次。

答案 5 :(得分:7)

你看过实例的控制台输出了吗?您可以通过AWS console(实例 - &gt;右键单击实例 - &gt;获取系统日志)来执行此操作。我曾经有过EC2实例上的网络服务无法正常启动的情况,导致SSH连接超时;重新启动实例通常是固定的。

答案 6 :(得分:2)

enter image description here

我发现这2小时之后

注意ssh ip 120.138.105.251/32

  • 不是实例IP ADDRESS

  • 这不是您的本地IP 127.0.0.1

  • 这不是您的本地IP localhost

但是但是

个人计算机您的公共IP地址,您尝试访问该实例

  1. 转到https://www.whatismyip.com/ ssh
  2. 中输入的任何IP地址

    如果您想完全打开SSH到所有IP地址 enter image description here

    这是如何完全可访问的条目 - 基本记录 enter image description here

    这就是我在生产中使用的东西 enter image description here

答案 7 :(得分:1)

应用规则后,只需重新启动Ec2实例

答案 8 :(得分:1)

允许ufw的ssh和端口22,然后将其启用并使用状态命令进行检查

sudo ufw allow ssh
sudo ufw allow 22
sudo ufw enable
sudo ufw status

答案 9 :(得分:1)

以下是可能的问题:

  • 最可能的一个是安全组未正确配置,无法在端口22上为您的i.p提供SSH访问。安全设置的更改不需要重新启动服务器以使其生效,但需要等待几分钟才能使其适用。

  • 本地防火墙配置不允许SSH访问服务器。 (你可以尝试不同的互联网连接,你的手机/加密狗试试吧)

  • 服务器未正确启动(即使在亚马逊控制台上访问检查也会失败),在这种情况下,您需要停止并启动服务器。

答案 10 :(得分:0)

连接在 MCI_Open(p_MediaFile,p_Alias="",p_Flags="") { Static s_Seq=0 ;[==============] ;[ Parameters ] ;[==============] ;-- p_MediaFile if p_MediaFile<>new { ;-- Media file exist? IfNotExist %p_MediaFile% { outputdebug, (ltrim join`s End Func: %A_ThisFunc%: The media file can't be found. Return=0 ) return false } ;-- "Type" flag not defined? if InStr(A_Space . p_Flags . A_Space," type ")=0 { ;-- Registered file extension? SplitPath p_MediaFile,,,l_Extension ;-- Which OS type? if A_OSType=WIN32_NT ;-- Windows NT4/2000/XP/2003/Vista RegRead ,l_Dummy ,HKEY_LOCAL_MACHINE ,SOFTWARE\Microsoft\Windows NT\CurrentVersion\MCI Extensions ,%l_Extension% else { ;-- Windows 95/98/ME iniRead ,l_Value ,%A_WinDir%\win.ini ,MCI Extensions ,%l_Extension% if l_Value=ERROR ErrorLevel=1 } ;-- Not found? if ErrorLevel { outputdebug, (ltrim join`s End Func: %A_ThisFunc%: The file extension for this media file is not registered as a valid MCI extension. Return=0 ) return false } } ;-- Enclose in DQ p_MediaFile="%p_MediaFile%" } ;-- Alias if p_Alias is Space { s_Seq++ p_Alias=MCIFile%s_Seq% } ;[===============] ;[ Open device ] ;[===============] l_CmdString=open %p_MediaFile% alias %p_Alias% %p_Flags% wait l_Return:=MCI_SendString(l_CmdString,Dummy) if l_Return l_Return:=0 else l_Return:=p_Alias ;-- Set time format to milliseconds if l_Return { l_CmdString=set %p_Alias% time format milliseconds wait MCI_SendString(l_CmdString,Dummy) } ;-- Return to sender return l_Return } MCI_OpenCDAudio(p_Drive="",p_Alias="",p_CheckForMedia=true) { Static s_Seq=0 ;-- Parameters p_Drive=%p_Drive% ;-- Autotrim p_Drive:=SubStr(p_Drive,1,1) if p_Drive is not Alpha p_Drive:="" ;-- Drive not specified if p_Drive is Space { ;-- Collect list of CDROM drives DriveGet l_ListOfCDROMDrives,List,CDROM if l_ListOfCDROMDrives is Space { outputdebug, (ltrim join`s End Func: %A_ThisFunc%: This PC does not have functioning CDROM drive. Return=0 ) return false } ;-- Assign the first CDROM drive p_Drive:=SubStr(l_ListOfCDROMDrives,1,1) } ;-- Is this a CDROM drive? DriveGet l_DriveType,Type,%p_Drive%: if l_DriveType<>CDROM { outputdebug, (ltrim join`s End Func: %A_ThisFunc%: The specified drive (%p_Drive%:) is not a CDROM drive. Return=0 ) return false } ;-- Alias if p_Alias is Space { s_Seq++ p_Alias=MCICDAudio%s_Seq% } ;-- Open device l_CmdString=open %p_Drive%: alias %p_Alias% type cdaudio shareable wait l_Return:=MCI_SendString(l_CmdString,Dummy) if l_Return l_Return:=0 else l_Return:=p_Alias ;-- Device is open if l_Return { ;-- Set time format to milliseconds l_CmdString=set %p_Alias% time format milliseconds wait MCI_SendString(l_CmdString,Dummy) ;-- Check for media? if p_CheckForMedia { if not MCI_MediaIsPresent(p_Alias) { MCI_Close(p_Alias) outputdebug, (ltrim join`s End Func: %A_ThisFunc%: Media is not present in the specified drive (%p_Drive%:). Return=0 ) return false } ;-- 1st track an audio track? if not MCI_TrackIsAudio(p_Alias,1) { MCI_Close(p_Alias) outputdebug, (ltrim join`s End Func: %A_ThisFunc%: Media in drive %p_Drive%: does not contain CD Audio tracks. Return=0 ) return false } } } return l_Return } MCI_Close(p_lpszDeviceID) { Static MM_MCINOTIFY:=0x03B9 ;-- Close device l_Return:=MCI_SendString("close " . p_lpszDeviceID . " wait",Dummy) ;-- Turn off monitoring of MM_MCINOTIFY message? if OnMessage(MM_MCINOTIFY)="MCI_Notify" { ;-- Don't proceed unless all MCI devices are closed MCI_SendString("sysinfo all quantity open",l_OpenMCIDevices) if l_OpenMCIDevices=0 { ;-- Disable monitoring OnMessage(MM_MCINOTIFY,"") } } return l_Return } MCI_Play(p_lpszDeviceID,p_Flags="",p_Callback="",p_hwndCallback=0) { Static MM_MCINOTIFY:=0x03B9 ;-- Build command string l_CmdString:="play " . p_lpszDeviceID if p_Flags l_CmdString:=l_CmdString . A_Space . p_Flags ;-- Notify p_Callback=%p_Callback% ;-- AutoTrim if StrLen(p_Callback) { l_CmdString:=l_CmdString . " notify" ;-- Attach p_Callback to MCI_Notify function MCI_Notify(p_Callback,"","","") ;-- Monitor for MM_MCINOTIFY message OnMessage(MM_MCINOTIFY,"MCI_Notify") ;-- Note: If the MM_MCINOTIFY message was monitored elsewhere, ; this statement will override it. } ;-- Callback handle if not p_hwndCallback { if InStr(A_Space . l_CmdString . A_Space," notify ") or StrLen(p_Callback) { l_DetectHiddenWindows:=A_DetectHiddenWindows DetectHiddenWindows On Process Exist p_hwndCallback:=WinExist("ahk_pid " . ErrorLevel . " ahk_class AutoHotkey") DetectHiddenWindows %l_DetectHiddenWindows% } } ;-- Send it! l_return:=MCI_SendString(l_CmdString,Dummy,p_hwndCallback) return l_Return } MCI_Notify(wParam,lParam,msg,hWnd) { ;;;;; Critical ;-- This will cause MM_MCINOTIFY messages to be buffered rather than ; discared if this function is still running when another MM_MCINOTIFY ; message is sent. Static s_Callback ;-- Internal call? if lParam is Space { s_Callback:=wParam return } ;-- Call developer function if s_Callback is not Space %s_Callback%(wParam) return 0 } MCI_Stop(p_lpszDeviceID) { l_Return:=MCI_SendString("stop " . p_lpszDeviceID . " wait",Dummy) return l_Return } MCI_Pause(p_lpszDeviceID) { l_Return:=MCI_SendString("pause " . p_lpszDeviceID . " wait",Dummy) return l_Return } MCI_Resume(p_lpszDeviceID) { l_Return:=MCI_SendString("resume " . p_lpszDeviceID . " wait",Dummy) return l_Return } MCI_Record(p_lpszDeviceID,p_Flags="") { l_CmdString=record %p_lpszDeviceID% %p_Flags% l_Return:=MCI_SendString(l_CmdString,Dummy) return l_Return } MCI_Save(p_lpszDeviceID,p_FileName) { l_CmdString=save %p_lpszDeviceID% "%p_FileName%" l_Return:=MCI_SendString(l_CmdString,Dummy) return l_Return } MCI_Seek(p_lpszDeviceID,p_Position) { ;-- Get current status l_Status:=MCI_Status(p_lpszDeviceID) ;-- Adjust p_Position if necessary if p_Position not in start,end { if p_Position is not Number p_Position=0 p_Position:=Round(p_Position) ;-- Integer values only if (p_Position>MCI_Length(p_lpszDeviceID)) p_Position:="end" else if p_Position<1 p_Position:="start" ;-- This is necessary because some devices don't like a "0" ; position. } ;-- Seek l_CmdString=seek %p_lpszDeviceID% to %p_Position% wait l_Return:=MCI_SendString(l_CmdString,Dummy) ;-- Return to mode before seek if l_Status in paused,playing { MCI_Play(p_lpszDeviceID) ;-- Re-pause if l_Status=paused MCI_Pause(p_lpszDeviceID) } l_CurrentPos:=MCI_Position(p_lpszDeviceID) ;-- Return to sender return l_Return } MCI_Length(p_lpszDeviceID,p_Track=0) { ;-- Build command string l_CmdString:="status " . p_lpszDeviceID . " length" if p_Track l_CmdString:=l_CmdString . " track " . p_Track ;-- Send it! MCI_SendString(l_CmdString,l_lpszReturnString) return l_lpszReturnString } MCI_Status(p_lpszDeviceID) { MCI_SendString("status " . p_lpszDeviceID . " mode",l_lpszReturnString) return l_lpszReturnString } MCI_Position(p_lpszDeviceID,p_Track=0) { ;-- Build command string l_CmdString:="status " . p_lpszDeviceID . " position" if p_Track l_CmdString:=l_CmdString . " track " . p_Track ;-- Send it! MCI_SendString(l_CmdString,l_lpszReturnString) return l_lpszReturnString } MCI_DeviceType(p_lpszDeviceID) { l_CmdString=capability %p_lpszDeviceID% device type MCI_SendString(l_CmdString,l_lpszReturnString) return l_lpszReturnString } MCI_MediaIsPresent(p_lpszDeviceID) { l_CmdString=status %p_lpszDeviceID% media present l_RC:=MCI_SendString(l_CmdString,l_lpszReturnString) if l_RC ;-- Probably invalid command for the device l_Return:=false else if (l_lpszReturnString="true") l_Return:=true else l_Return:=false return l_Return } MCI_TrackIsAudio(p_lpszDeviceID,p_Track=1) { if p_Track is not Integer p_Track=1 l_CmdString=status %p_lpszDeviceID% type track %p_Track% l_RC:=MCI_SendString(l_CmdString,l_lpszReturnString) if l_RC ;-- Probably invalid command for the device l_Return:=false else if l_lpszReturnString=audio l_Return:=true else l_Return:=false return l_Return } MCI_CurrentTrack(p_lpszDeviceID) { l_CmdString:="status " . p_lpszDeviceID . " current track" l_Return:=MCI_SendString(l_CmdString,l_lpszReturnString) return l_lpszReturnString } MCI_NumberOfTracks(p_lpszDeviceID) { l_CmdString:="status " . p_lpszDeviceID . " number of tracks" l_Return:=MCI_SendString(l_CmdString,l_lpszReturnString) return l_lpszReturnString } MCI_SetVolume(p_lpszDeviceID,p_Factor) { l_CmdString:="setaudio " . p_lpszDeviceID . " volume to " . p_Factor l_Return:=MCI_SendString(l_CmdString,Dummy) return l_Return } MCI_SetBass(p_lpszDeviceID,p_Factor) { l_CmdString:="setaudio " . p_lpszDeviceID . " bass to " . p_Factor l_Return:=MCI_SendString(l_CmdString,Dummy) return l_lpszReturnString } MCI_SetTreble(p_lpszDeviceID,p_Factor) { l_CmdString:="setaudio " . p_lpszDeviceID . " treble to " . p_Factor l_Return:=MCI_SendString(l_CmdString,Dummy) return l_lpszReturnString } MCI_ToMilliseconds(Hour,Min,Sec) { milli:=Sec*1000 milli += (Min*60)*1000 milli += (Hour*3600)*1000 return milli } MCI_ToHHMMSS(p_ms,p_MinimumSize=4) { ;-- Convert p_ms to whole seconds if p_ms is not Number l_Seconds=0 else if p_ms<0 l_Seconds=0 else l_Seconds:=floor(p_ms/1000) ;-- Initialize and format l_Time=20121212 ;-- Midnight of an arbitrary date EnvAdd l_Time,l_Seconds,Seconds FormatTime l_mmss,%l_Time%,mm:ss l_FormattedTime:="0" . l_Seconds//3600 . ":" . l_mmss ;-- Allows support for more than 24 hours. ;-- Trim insignificant leading characters loop if StrLen(l_FormattedTime)<=p_MinimumSize break else if SubStr(l_FormattedTime,1,1)="0" StringTrimLeft l_FormattedTime,l_FormattedTime,1 else if SubStr(l_FormattedTime,1,1)=":" StringTrimLeft l_FormattedTime,l_FormattedTime,1 else break ;-- Return to sender return l_FormattedTime } MCI_SendString(p_lpszCommand,ByRef p_lpszReturnString,p_hwndCallback=0) { VarSetCapacity(p_lpszReturnString,100,0) l_Return:=DllCall("winmm.dll\mciSendStringA" ,"str",p_lpszCommand ;-- lpszCommand ,"str",p_lpszReturnString ;-- lpszReturnString ,"uint",100 ;-- cchReturn ,"uint",p_hwndCallback ;-- hwndCallback ,"Cdecl int") ;-- Return type if ErrorLevel MsgBox ,262160 ;-- 262160=0 (OK button) + 16 (Error icon) + 262144 (AOT) ,%A_ThisFunc% Function Error, (ltrim join`s Unexpected ErrorLevel from DllCall to the "winmm.dll\mciSendStringA" function. ErrorLevel=%ErrorLevel% %A_Space% `nSee the AutoHotkey documentation (Keyword: DLLCall) for more information. %A_Space% ) ;-- Return code? if l_Return { VarSetCapacity(l_MCIErrorString,1024) DllCall("winmm\mciGetErrorStringA" ,"uint",l_Return ;-- MCI error number ,"str",l_MCIErrorString ;-- MCI error text ,"uint",1024) ;-- This is provided to help debug MCI calls outputdebug, (ltrim join`s End Func: %A_ThisFunc%: Unexpected return code from command string: "%p_lpszCommand%" `n--------- Return code=%l_Return% - %l_MCIErrorString% ) } return l_Return } 期间获得 timed-out 可能有多种原因。我见过的其中一种情况是您的 sshroute 没有关联。

enter image description here

答案 11 :(得分:0)

您可以尝试使用您的 ec2 实例网址。 例如

ssh -i "yourkey.pem" ubuntu@ec2-XX-XXX-XX-XX.ap-south-1.compute.amazonaws.com

答案 12 :(得分:0)

如果您刚刚创建了一个新实例并且无法连接到该实例,那么我可以通过终止该实例并创建一个新实例来解决该问题。当然,只有在它是新实例并且您没有对其进行任何更多工作的情况下,它才起作用。

答案 13 :(得分:0)

首先

ping DNS。如果失败,则在启动向导中配置入站/出站规则。配置所有流量和所有协议,并使用默认选项保存。再次与您的本地系统ping通,然后应该可以正常工作

答案 14 :(得分:0)

我正在处理实例,这很好,第二天,当我尝试通过SSH进入实例时,它说-连接超时。

我试图浏览这篇文章,但没有任何效果。所以我做到了-

在源列的Edit inbound rules上选择MY IP,它将自动以CIDR格式(XXX.XXX.XXX.XX/32)填充您的公共IP地址。

我尝试通过提供本地IP来使用@ ted.strauss答案,但对我的情况没有帮助。所以我选择了我的IP,它起作用了。

希望这对某人有帮助!

答案 15 :(得分:0)

对我来说,那是我已从引导卷中删除了所有内容。并且无法再连接到该实例。

答案 16 :(得分:0)

我遇到了同样的问题,并通过向安全组中添加规则来解决了这个问题

入站SSH 0.0.0.0/0

或者您只能添加IP地址

答案 17 :(得分:0)

就我而言,实例是可访问的,但突然变得无法访问。

我刚刚从 aws 控制台重新启动实例,它解决了我的问题。

答案 18 :(得分:0)

建立@ted.strauss的回答,您可以从下拉菜单中选择SSHMyIP,而不是导航到第三方网站。

答案 19 :(得分:0)

对我来说,它是托管在t2.micro linux EC2实例上的apache服务器,而不是EC2实例本身。

我通过这样做来修复它:

sudo su

service httpd restart

答案 20 :(得分:0)

要为Internet上的VPC子网中的实例启用ssh访问,请执行以下操作:

  • 将Internet网关连接到您的VPC。
  • 确保子网的路由表指向Internet网关。
  • 确保子网中的实例具有全局唯一的IP地址(公用IPv4地址,弹性IP地址或IPv6地址)。
  • 确保您的网络访问控制(在VPC级别)和安全组规则(在ec2级别)允许相关流量流入和流出您的实例。确保为两者启用了网络公共IP地址。默认情况下,Network AcL允许除明确配置之外的所有入站和出站流量

答案 21 :(得分:0)

我的问题 - 我的端口22打开了#34;我的IP&#34;并改变了互联网连接和IP地址变化造成的。所以不得不改回来。

答案 22 :(得分:0)

查看AWS文档上的此帮助页面:

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/TroubleshootingInstancesConnecting.html#TroubleshootingInstancesConnectionTimeout 你可能会在那里找到你的解决方案。对我来说,这部分做了修复:

  

[EC2-VPC]检查子网的路由表。你需要一条路线   将发往VPC外部的所有流量发送到Internet网关   VPC。

     
      
  • https://console.aws.amazon.com/vpc/

  • 打开Amazon VPC控制台   
  • 在导航窗格中,选择“Internet网关”。验证是否有连接到VPC的Internet网关。否则,选择Create   Internet网关并按照说明创建Internet   网关,选择Internet网关,然后选择附加到VPC   并按照说明将其附加到您的VPC。

  •   
  • 在导航窗格中,选择Subnets,然后选择您的子网。

  •   
  • 在“路由表”选项卡上,验证是否存在以0.0.0.0/0作为目标的路由以及作为VPC的Internet网关   目标。否则,请选择路由表(rtb-xxxxxxxx)的ID   导航到路径表的Routes选项卡,选择Edit,Add   另一条路线,在目的地输入0.0.0.0/0,选择您的互联网   来自Target的网关,然后选择保存。

  •   

但我建议你查看上面链接所涵盖的所有选项,你可能会发现你遇到的一个或多个问题。

答案 23 :(得分:0)

如果SSH访问对您的EC2实例不起作用,则需要检查:

    您实例的
  • 安全组 允许入站 SSH访问(请检查:查看规则)。

如果您正在使用附加到您的实例的VPC实例(您已经 VPC ID 子网ID ),请检查:

  1. 在VPC仪表板中,找到附加到您的VPC的已使用的子网ID。
  2. 检查其附加的路由表 ,其中0.0.0.0/0为目标, Internet网关为目标。
  3. 在Linux上,您还可以在实例的 Networking 中的系统日志中检查路由信息,例如:

    ++++++++++++++++++++++++++++++++++++++Net device info+++++++++++++++++++++++++++++++++++++++
    +--------+------+------------------------------+---------------+-------+-------------------+
    | Device |  Up  |           Address            |      Mask     | Scope |     Hw-Address    |
    +--------+------+------------------------------+---------------+-------+-------------------+
    |   lo   | True |          127.0.0.1           |   255.0.0.0   |   .   |         .         |
    |  eth0  | True |         172.30.2.226         | 255.255.255.0 |   .   | 0a:70:f3:2f:82:23 |
    +--------+------+------------------------------+---------------+-------+-------------------+
    ++++++++++++++++++++++++++++Route IPv4 info+++++++++++++++++++++++++++++
    +-------+-------------+------------+---------------+-----------+-------+
    | Route | Destination |  Gateway   |    Genmask    | Interface | Flags |
    +-------+-------------+------------+---------------+-----------+-------+
    |   0   |   0.0.0.0   | 172.30.2.1 |    0.0.0.0    |    eth0   |   UG  |
    |   1   |   10.0.3.0  |  0.0.0.0   | 255.255.255.0 |   lxcbr0  |   U   |
    |   2   |  172.30.2.0 |  0.0.0.0   | 255.255.255.0 |    eth0   |   U   |
    +-------+-------------+------------+---------------+-----------+-------+
    

    其中UG标志显示您的互联网网关。

    有关详细信息,请查看:亚马逊文档中的Troubleshooting Connecting to Your Instance

答案 24 :(得分:0)

当我使用没有密码的公共Wifi时,我遇到了类似的问题。将互联网连接切换到安全连接确实解决了这个问题。

答案 25 :(得分:0)

我遇到了同样的问题,解决方案是允许从任何地方访问活动安全组中的入站规则列表。在入站对话框中,在源字段中的端口范围中输入22,任何地方,然后在下拉列表中选择“ssh”。

P.S:这可能不是推荐的解决方案,因为它意味着这个实例可以从任何机器上ssh'ed,但我无法使用我的本地IP。

答案 26 :(得分:0)

还有一种可能性。 AWS安全组设置为仅适用于特定的传入IP地址。如果您的安全组以这种方式设置,您(或帐户持有者)将需要将您的IP地址添加到安全组。 Todo打开您的AWS仪表板,选择安全组,选择安全组并单击入站选项卡。然后根据需要添加你的IP。