PHPackages                             hparadiz/aws-instance-connect - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. hparadiz/aws-instance-connect

ActiveProject[HTTP &amp; Networking](/categories/http)

hparadiz/aws-instance-connect
=============================

Uses AWS Instance Connect API to authorize an SSH key and automatically runs the SSH command using that key for you.

0.4(4y ago)89MITPHP

Since Apr 13Pushed 4y ago2 watchersCompare

[ Source](https://github.com/hparadiz/aws-instance-connect)[ Packagist](https://packagist.org/packages/hparadiz/aws-instance-connect)[ RSS](/packages/hparadiz-aws-instance-connect/feed)WikiDiscussions main Synced today

READMEChangelog (4)Dependencies (6)Versions (5)Used By (0)

AWS Instance Connect PHP
========================

[](#aws-instance-connect-php)

[![Latest Unstable Version](https://camo.githubusercontent.com/d2fcd2419687d617ad1ff890e424f7fae3aa95902900b00809eca3ba2436dd6a/68747470733a2f2f706f7365722e707567782e6f72672f687061726164697a2f6177732d696e7374616e63652d636f6e6e6563742f762f737461626c65)](https://packagist.org/packages/hparadiz/aws-instance-connect)[![License](https://camo.githubusercontent.com/1fd2fc0a5a738c49cc6b9bd017c5ffaf321e6e0296cf1cc3af0fdf579df1ae9c/68747470733a2f2f706f7365722e707567782e6f72672f687061726164697a2f6177732d696e7374616e63652d636f6e6e6563742f6c6963656e7365)](https://packagist.org/packages/hparadiz/aws-instance-connect)

This tool lets you SSH into AWS EC2 instances with nothing but your AWS IAM credentials that you probably already have in your home directory if you work with AWS.

To be more specific it uses the AWS SDK to access AWS Instance Connect to SSH into your EC2 instances quickly with a high degree of security because a key is generated for one time use and then immediately destroyed.

[![asciicast](https://camo.githubusercontent.com/c65fa83841ce12a225eda7ca93c83fd5750e654b79c2917e95e008d579f126c6/68747470733a2f2f61736369696e656d612e6f72672f612f464d78636a4959754b617558506d346b5646523032675171742e737667)](https://asciinema.org/a/FMxcjIYuKauXPm4kVFR02gQqt)

Installation
------------

[](#installation)

`composer global require hparadiz/aws-instance-connect`

Configuration
-------------

[](#configuration)

Please follow the AWS instructions for setting up your AWS credentials in `~/.aws/credentials`

The default region will be pulled from `~/.aws/config`

Setup
-----

[](#setup)

1. Go to IAM -&gt; Policies in your AWS console.
2. Create a new JSON policy.
3. Paste this in and save.

```
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": "ec2-instance-connect:SendSSHPublicKey",
            "Resource": "arn:aws:ec2:region:account-id:instance/*"
        },
        {
            "Effect": "Allow",
            "Action": "ec2:DescribeInstances",
            "Resource": "*"
        }
    ]
}
```

This policy will allow AWS Instance Connect to work with all your EC2 instances in all regions. Please refer to AWS documentation for more targeted security policy rules.

Usage via CLI
-------------

[](#usage-via-cli)

```
$ ic --help
Usage: ic [options] [] [operands]

Operands:
  []  Target instance

Options:
  -v, --version       Show version information and quit
  -h, --help          Show this help and quit
  -N, --no-connect    Authorize the SSH key and exit.
  -u, --user     Set user for SSH connection. Defaults to ubuntu.
  -R, --region   AWS Region
  -n, --name     The name of the instance (AWS Tag 'Name')

```

Usage with code
---------------

[](#usage-with-code)

```
$IC = new InstanceConnect();
$IC->region = 'us-east-1';

// the username for the SHH connection
$IC->user = 'ubuntu';

// optional (will prompt for an instance if not set)
$IC->name = 'i-0e19ee2d63877633f';

$IC->publicKey = '/home/user/.ssh/rsa.pub';
$IC->privateKey = '/home/user/.ssh/rsa';

// for the key to be authorized but for no SSH connection to be created
// to use the key with something else like SCP or a tunnel
$IC->noConnect = false;

$IC->start();
```

FAQ
---

[](#faq)

### Why?

[](#why)

By using AWS credentials to login instead of SSH keys it is easier to manage your users and you can actually withdraw access without having to manually delete any keys. You can add or remove users simply by adding or removing them from your AWS console through the normal user management interface.

### Okay but seriously. Is this secure?

[](#okay-but-seriously-is-this-secure)

The code is super simple. Only about 200 lines of code. Feel free to read it. I make use of phpseclib to make the keys and the official AWS SDK does the actual leg work.

### Why PHP?

[](#why-php)

Since I work with PHP projects this is just conveniant for me.

Support
=======

[](#support)

I wrote this tool for myself but I hope others find it useful. I'm happy to work on this further if people begin to use it. Feel free to make feature requests. I'm eager to hear about other use cases.

If you wish to support this project please see the links below.

Ko-Fi:

BTC - bc1qqqejxpuxgeyxx5fkyan8tpeuwyenks8fa4zldf

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~2 days

Total

4

Last Release

1483d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/545f90a81089828771a6eaf9c2d49f8338bf5a3577ed9e0da12b1006361ea79a?d=identicon)[hparadiz](/maintainers/hparadiz)

---

Top Contributors

[![hparadiz](https://avatars.githubusercontent.com/u/195216?v=4)](https://github.com/hparadiz "hparadiz (11 commits)")

### Embed Badge

![Health badge](/badges/hparadiz-aws-instance-connect/health.svg)

```
[![Health](https://phpackages.com/badges/hparadiz-aws-instance-connect/health.svg)](https://phpackages.com/packages/hparadiz-aws-instance-connect)
```

###  Alternatives

[akamai-open/edgegrid-client

Implements the Akamai {OPEN} EdgeGrid Authentication specified by https://developer.akamai.com/introduction/Client\_Auth.html

482.5M6](/packages/akamai-open-edgegrid-client)[georgeboot/laravel-echo-api-gateway

Use Laravel Echo with API Gateway Websockets

10435.5k](/packages/georgeboot-laravel-echo-api-gateway)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
