Code Monkey home page Code Monkey logo

psec2rdp's Introduction

[Experimental] PSEC2RDP

Remote Desktop Utility for Amazon EC2.

Notes

This repository is experimental.

Recommend using ec2rdp.

How to install

Currently, No plans to publish this module.

# Clone this repository and execute Import-Module manually.
git clone https://github.com/stknohg/PSEC2RDP.git
Import-Module .\PSEC2RDP\PSEC2RDP\ -Force

Prerequisites

Functions

Start-EC2RDPClient

Connect to public EC2 instance with Remote Desktop Client.

Start-EC2RDPClient 'EC2 Instance ID' -PemFile 'Path to private key file (.pem)'

Example

# Setup your profile
PS C:\> Set-AWSCredential -ProfileName your_profile
PS C:\> Set-DefaultAWSRegion ap-northeast-1

# Connect to EC2
PS C:\> Start-EC2RDPClient i-01234567890abcdef -PemFile C:\project\example.pem

Start-EC2RDPClient example

Start-SSMRDPClient

Connect to EC2 instance with Remote Desktop Client via SSM port forwarding.

Note
You need to use shared credentials file (same as AWS CLI credentials) to set your profile .

Start-SSMRDPClient 'EC2 Instance ID' -PemFile 'Path to private key file (.pem)'

Example

# Setup your profile
PS C:\> Set-AWSCredential -ProfileName your_profile
PS C:\> Set-DefaultAWSRegion ap-northeast-1

# Connect to EC2 via SSM port forwarding
PS C:\> Start-SSMRDPClient i-01234567890abcdef -PemFile C:\project\example.pem

Start-SSMRDPClient example

Start-SSMSessionEx

Start SSM session and execute session-manager-plugin process.

Note
You need to use shared credentials file (same as AWS CLI credentials) to set your profile .

Start-SSMSessionEx -Target 'EC2 Instance ID' -DocumentName 'SSM document name' -Parameter 'SSM document parameters'

Example.1

Connect EC2 instance by default.

# Setup your profile
PS C:\> Set-AWSCredential -ProfileName your_profile
PS C:\> Set-DefaultAWSRegion ap-northeast-1

# Start SSM Session 
PS C:\> Start-SSMSessionEx -Target i-01234567890abcdef

Start-SSMSessionEx example.1

# You can use -PassThru parameter
PS C:\> $result = Start-SSMSessionEx -Target i-01234567890abcdef -PassThru
Starting session with SessionId: aws-dotnet-sdk-session-xxxxxxxxxxxxxxxxxx-yyyyyyyyyyyyyyyyy
Start session-manager-plugin process (24776)

# In this case, you must close SSM Session manually
PS C:\> Stop-SSMSession -SessionId $result.Session.SessionId
aws-dotnet-sdk-session-xxxxxxxxxxxxxxxxxx-yyyyyyyyyyyyyyyyy
# If needed, terminate session-manager-plugin manually
PS C:\> Stop-Process $result.Process.Id -ErrorAction Ignore

Example.2

You can do port forwarding with this function.

# Start RDP port forwarding
PS C:\> $params = @{
>>     Target       = 'i-01234567890abcdef'
>>     DocumentName = 'AWS-StartPortForwardingSession'
>>     Parameter    = @{portNumber = @('3389'); localPortNumber = @('33389') }
>> }
PS C:\> Start-SSMSessionEx @params

Start-SSMSessionEx example.2

License

psec2rdp's People

Contributors

stknohg avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.