You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

新加坡区域新启动免费层Linux实例SSH密钥连接失败求助

Hey Eleena, sorry to hear you're stuck with SSHing into your new Singapore region free-tier Linux instance—let's work through this step by step to fix that Permission denied (publickey,gssapi-keyex,gssapi-with-mic) error!

Common Fixes to Try

  • Lock down your local PEM file permissions first
    Linux is super strict about private key security—if your PEM file has too open permissions (like readable by other users), SSH will flat-out reject it. Run this on your local machine (swap your-key.pem with your actual key filename):

    chmod 600 your-key.pem
    

    This restricts access to only you, which is a non-negotiable requirement for SSH to use the key.

  • Double-check your SSH command syntax (especially the username)
    Different Linux distros use different default usernames for cloud instances—using the wrong one will trigger a permission error. Here are the most common defaults:

    • Amazon Linux 2/2023: ec2-user
    • Ubuntu: ubuntu
    • Debian: admin or debian
    • RHEL/CentOS: ec2-user (or root in rare cases)

    Your command should look like this (fill in your details):

    ssh -i "your-key.pem" correct-username@your-instance-public-ip
    

    You can also use the instance's public DNS instead of the IP if that's easier.

  • Make sure your instance's security group allows SSH traffic
    Even with a perfect key, if the security group blocks port 22, you can't connect. Head to your cloud console:

    1. Go to your instance's details page
    2. Click on the security group linked to your instance
    3. Check the inbound rules—there should be a rule for SSH (22) that allows traffic from your public IP (use the "My IP" option in the console to auto-fill this, or use 0.0.0.0/0 temporarily for testing—just remember to tighten it later)
    4. If no such rule exists, add it right away.
  • Confirm you're using the exact key pair you selected at launch
    It's easy to mix up key pairs when spinning up a new instance. Double-check:

    1. In the instance details, look for the "Key pair name" field
    2. Compare it to the name of your PEM file—if they don't match, you have two options:
      • Terminate this instance and launch a new one with the correct key pair (the simplest route for free-tier instances)
      • Go through the more complex process of injecting a new key pair into the running instance (not recommended unless you're comfortable with cloud instance recovery)
  • Give the instance a minute to fully initialize
    Newly launched instances often take 2-5 minutes to finish booting up and configure SSH services. If you tried connecting immediately after launch, wait a bit and try again.

  • Debug with verbose SSH output
    If none of the above works, run the SSH command with -v to get detailed logs about where the connection is failing:

    ssh -v -i "your-key.pem" correct-username@your-instance-public-ip
    

    Look for lines like "Offering public key" or "Server refused our key"—these will point you to whether the key is being recognized or if there's another underlying issue.

Hope one of these fixes gets you connected smoothly!

内容的提问来源于stack exchange,提问作者Eleena jose

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 11:29:22