Skip to content
play

GitHub Action

Setup SSH for EC2

v1.0.0 Latest version

Setup SSH for EC2

play

Setup SSH for EC2

Setup SSH for connecting to an EC2 instance

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Setup SSH for EC2

uses: omarhosny206/[email protected]

Learn more about this action in omarhosny206/setup-ssh-for-ec2

Choose a version

Release v1.0.0 - Initial Release

🎉 We are excited to announce the initial release of the "Setup SSH for EC2" GitHub Action! This action simplifies the process of setting up SSH for connecting to an EC2 instance.

Key Features:

  • SSH Configuration:
    • Automatically configures SSH settings based on provided private key and EC2 instance URL.

How to Use:

  • In your workflow, use the Setup SSH for EC2 action.
  • Provide the required input parameters:
    • EC2_SSH_PRIVATE_KEY: The private key of EC2 instance for SSH connection.
    • EC2_URL: The URL of the EC2 instance.

Usage:

name: Setup SSH for EC2 instance

on:
  push:
    branches:
      - master

jobs:
  setup-ssh:
    runs-on: ubuntu-latest
    env:
      EC2_SSH_PRIVATE_KEY: ${{ secrets.EC2_SSH_PRIVATE_KEY }}
      EC2_URL: ${{ secrets.EC2_URL }}
      EC2_USERNAME: ${{ secrets.EC2_USERNAME }}
    steps:
    - name: Setup SSH for EC2
      uses: omarhosny206/[email protected]
      with:
          EC2_SSH_PRIVATE_KEY: $EC2_SSH_PRIVATE_KEY
          EC2_URL: $EC2_URL
    # then you can run commands/scripts directly on the EC2 instance e.g.:
    - name: Create a new file on the EC2 instance with "hello-world"
      run: ssh -o StrictHostKeyChecking=no $EC2_USERNAME@$EC2_URL "echo "hello-world" >> new_file.txt"