Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
Sichere ProgrammierungLarge AI Labs Face Regulatory Capture Allegations(21.09.2026 um 05:18 Uhr)
Sichere ProgrammierungWhat people are building with Jev: a look through nine awesome lists(21.09.2026 um 05:44 Uhr)
IT Security Toolsnetwatch v0.32.3(21.09.2026 um 04:36 Uhr)
Sichere ProgrammierungLarge AI Labs Face Regulatory Capture Allegations(21.09.2026 um 05:18 Uhr)
Sichere ProgrammierungWhat people are building with Jev: a look through nine awesome lists(21.09.2026 um 05:44 Uhr)
IT Security Toolsnetwatch v0.32.3(21.09.2026 um 04:36 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

SSH to your AWS EC2 instances using EC2-connect eice using this alias

Reagiere als Erste:r — dein Feedback zählt!

We recently switched all of our EC2 instances to use EC2-connect to gain CLI access to all the servers. This mean no more SSH keys. We now use AWS SSO to authenticate our local machine's shell and then use the aws cli utilities to connect to each server using EC2-connect with an EC2 Instance Connect Endpoint (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/connect-using-eice.html)

We wrote ourselves a little shell function to alias ssh'ing to any server in any region without having to know the instance id. You just need to know something from the server's name and optionally the server's region.

Here is the function you can include in your .bashrc file:

function nb-ssh-eice(){
  local -r query="${1}"
  local -r region_in="${2}"

  declare -a all_regions
  if [ -z $region_in ]; then
    all_regions=($(aws ec2 describe-regions --query "Regions[].RegionName" --output json | jq -r '.[]'))
  else
    all_regions+=("$region_in")    
  fi

  for region in "${all_regions[@]}"; do
    echo "looking in ${region} for ${query}..."
    instance_id=$(aws ec2 describe-instances --region="${region}" --filter "Name=tag:Name,Values=${query}" \
                     'Name=instance-state-name,Values=running' \
                   --query 'Reservations[].Instances[].InstanceId' \
                   --output text)
  done

  if [ -z "${instance_id}" ]; then
      echo "EC2 instance not found."
  elif [ $(echo "${instance_id}" | wc -w) -gt 1 ]; then
      echo "Multiple EC2 instances found matching your query. Narrow down your query."
  else
    echo "---------------------------------------------------------------------------"
    echo "---  Logging into: Instance-Id: ${instance_id} -- Region: ${region}"
    echo "---------------------------------------------------------------------------"
    aws ec2-instance-connect ssh --region="${region}" \
                                 --os-user ubuntu \
                                 --instance-id="${instance_id}" \
                                 --connection-type eice
  fi
}
  1. It takes two arguments: query and region_in.
  2. It first checks if region_in is empty. If it is, it retrieves all AWS regions using the AWS CLI (aws ec2 describe-regions), otherwise, it adds the provided region to the all_regions array.
  3. Then, for each region in the all_regions array, it searches for instances matching the provided query using the AWS CLI (aws ec2 describe-instances). It filters the instances by their state (running) and extracts their instance IDs.
  4. If no instances are found, it outputs "EC2 instance not found."
  5. If multiple instances are found, it outputs "Multiple EC2 instances found matching your query. Narrow down your query."
  6. If a single instance is found, it outputs information about the instance (ID and region) and initiates an SSH connection to the instance using the AWS EC2 Instance Connect feature (aws ec2-instance-connect ssh).

Examples:

ssh-eice "*test1" us-east-2

You can even pass a command to run remotely:

echo "ls -la" | ssh-eice "*test1" us-east-2

I hope this helps save you some time as it did for us.

Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten SSH to your AWS EC2 instances using EC2-connect eice using this alias

Thematisch verwandte Begriffe: your, instances, using, EC2connect · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-94104 | NivoCart through 2.4.0 contains an arbitrary file upload vulnerability i…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick