Skip to content

Commit

Permalink
Initial commit of session-manager-plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Yangtao-Hua committed May 25, 2021
1 parent 79aec8c commit 65933d1
Show file tree
Hide file tree
Showing 4,547 changed files with 3,525,575 additions and 12 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.DS_Store
.idea/
*.iml
/Tools/bin/
/Tools/pkg/
/Tools/src/github.com/
/Tools/src/golang.org/
bin/
build
/vendor/bin/
/vendor/pkg/
.vscode/
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ reported the issue. Please try to include as much information as you can. Detail
## Contributing via Pull Requests
Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that:

1. You are working against the latest source on the *main* branch.
1. You are working against the latest source on the *mainline* branch.
2. You check existing open, and recently merged, pull requests to make sure someone else hasn't addressed the problem already.
3. You open an issue to discuss any significant work - we would hate for your time to be wasted.

Expand Down Expand Up @@ -56,4 +56,4 @@ If you discover a potential security issue in this project we ask that you notif

## Licensing

See the [LICENSE](LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution.
Session Manager Plugin is licensed under the Apache 2.0 License. We will ask you to confirm the licensing of your contribution.
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM golang:1.15

RUN apt -y update && apt -y upgrade && apt -y install rpm tar gzip wget zip && apt clean all

RUN mkdir /session-manager-plugin
WORKDIR /session-manager-plugin
29 changes: 28 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

Apache License
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/

Expand Down Expand Up @@ -173,3 +173,30 @@
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.

END OF TERMS AND CONDITIONS

APPENDIX: How to apply the Apache License to your work.

To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
1 change: 1 addition & 0 deletions NOTICE
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Session Manager Plugin
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
83 changes: 74 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,82 @@
## My Project

TODO: Fill this README out!
# Session Manager Plugin

Be sure to:
This plugin helps you to use the AWS Command Line Interface (AWS CLI) to start and end sessions to your managed instances. Session Manager is a capability of AWS Systems Manager.

* Change the title in this README
* Edit your repository description on GitHub
## Overview

## Security
Session Manager is a fully managed AWS Systems Manager capability that lets you manage your Amazon Elastic Compute Cloud (Amazon EC2) instances, on-premises instances and virtual machines. Session Manager provides secure and auditable instance management without the need to open inbound ports. When you use the Session Manager plugin with the AWS CLI to start a session, the plugin builds the websocket connection to your managed instances.

See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information.
### Prerequisites

## License
Before using Session Manager, make sure your environment meets the following requirements. [Complete Session Manager prerequisites](http://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-prerequisites.html).

### Starting a session

For information about starting a session using the AWS CLI, see [Starting a session (AWS CLI)](https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-working-with-sessions-start.html#sessions-start-cli).

### Troubleshooting

For information about troubleshooting, see [Troubleshooting Session Manager](http://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-troubleshooting.html).


### Working with Docker

To build the Session Manager plugin in a `Docker` container, complete the following steps:

1. Install [`docker`](https://docs.docker.com/engine/install/centos/)

2. Build the `docker` image
```
docker build -t session-manager-plugin-image .
```
3. Build the plugin
```
docker run -it --rm --name session-manager-plugin -v `pwd`:/session-manager-plugin session-manager-plugin-image make release
```

### Working with Linux

To build the binaries required to install the Session Manager plugin, complete the following steps.

1. Install `golang`

2. Install `rpm-build` and `rpmdevtools`

This project is licensed under the Apache-2.0 License.
3. Install `gcc 8.3+` and `glibc 2.27+`

4. Run `make release` to build the plugin for Linux, Debian, macOS and Windows.

5. Change to the directory of your local machine's operating system architecture and open the `session-manager-plugin` directory. Then follow the installation procedure that applies to your local machine. For more information, see [Install the Session Manager plugin for the AWS CLI](https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-working-with-install-plugin.html). If the machine you're building the plugin on differs from the machine you plan to install the plugin on you will need to copy the `session-manager-plugin` binary to the appropriate directory for that operating system.

```
Linux - /usr/local/sessionmanagerplugin/bin/session-manager-plugin
macOS - /usr/local/sessionmanagerplugin/bin/session-manager-plugin
Windows - C:\Program Files\Amazon\SessionManagerPlugin\bin\session-manager-plugin.exe
```

The `ssmcli` binary is available for some operating systems for testing purposes only. The following is an example command using this binary.

```
./ssmcli start-session --instance-id i-1234567890abcdef0 --region us-east-2
```

### Directory structure

Source code

* `sessionmanagerplugin/session` contains the source code for core functionalities
* `communicator/` contains the source code for websocket related operations
* `vendor/src` contains the vendor package source code
* `packaging/` contains rpm and dpkg artifacts
* `Tools/src` contains build scripts

## Feedback

Thank you for helping us to improve the Session Manager plugin. Please send your questions or comments to the [Systems Manager Forum](https://forums.aws.amazon.com/forum.jspa?forumID=185&start=0)

## License

The session-manager-plugin is licensed under the Apache 2.0 License.
55 changes: 55 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
Latest
================
- Enhancement: Added support for running session in NonInteractiveCommands execution mode.

1.2.30.0
================
- Bug Fix: (Port forwarding sessions only) Using system tmp folder for unix socket path.

1.2.7.0
================
- Enhancement: (Port forwarding sessions only) Reduced latency and improved overall performance.

1.1.61.0
================
- Enhancement: Added ARM support for Linux and Ubuntu.

1.1.54.0
================
- Bug Fix: Handle race condition scenario of packets being dropped when plugin is not ready.

1.1.50.0
================
- Enhancement: Add support for forwarding port session to local unix socket.

1.1.35.0
================
- Enhancement: For port forwarding session, send terminateSession flag to SSM agent on receiving Control-C signal.

1.1.33.0
================
- Enhancement: For port forwarding session, send disconnect flag to server when client drops tcp connection.

1.1.31.0
================
- Enhancement: Change to keep port forwarding session open until remote server closes the connection.

1.1.26.0
================
- Enhancement: Limit the rate of data transfer in port session.

1.1.23.0
================
- Enhancement: Add support for running SSH sessions using Session Manager.

1.1.17.0
================
- Enhancement: Add support for further encryption of session data using AWS KMS.

1.0.37.0
================
- Fix bug for Windows SessionManagerPlugin

1.0.0.0
================
- Initial SessionManagerPlugin release
90 changes: 90 additions & 0 deletions THIRD-PARTY
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
The Amazon Session Manager Plugin constitutes AWS Content as defined in the AWS Customer Agreement
or your relevant customer agreement with AWS, and is licensed to you under that agreement.

The Amazon Session Manager Plugin includes the following third-party software/licensing:

** cihub/seelog - https://github.com/cihub/seelog
Copyright (c) 2012, Cloud Instruments Co., Ltd. <[email protected]>. All rights reserved.
** gorilla/websocket - https://github.com/gorilla/websocket
Copyright (c) 2013 The Gorilla WebSocket Authors. All rights reserved.
** fsnotigy/fsnotify - https://github.com/fsnotify/fsnotify
Copyright (c) 2012 The Go Authors. All rights reserved.
Copyright (c) 2012 fsnotify Authors. All rights reserved.

BSD License

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Cloud Instruments Co., Ltd. nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

----------------

** twinj/uuid - https://github.com/twinj/uuid
Copyright (C) 2011 by Krzysztof Kowalik <[email protected]>
Copyright (C) 2016 by Daniel Kemp <[email protected]> Derivative work
** stretchr/testify - https://github.com/stretchr/testify
Copyright (c) 2012 - 2013 Mat Ryer and Tyler Bunnell
** stretchr/objx - https://github.com/stretchr/objx
Copyright (c) 2014 Stretchr, Inc.
Copyright (c) 2017-2018 objx contributors
** eiannone/keyboard - https://github.com/eiannone/keyboard
Copyright (C) 2012 termbox-go authors
Copyright (c) 2015 Emanuele Iannone
**xtaci/smux - https://github.com/xtaci/smux
Copyright (c) 2016-2017 Daniel Fu

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

----------------

jmespath/go-jmespath - https://github.com/jmespath/go-jmespath

Copyright 2015 James Saryerwinnie

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
33 changes: 33 additions & 0 deletions Tools/src/checkstyle.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash
echo "Run checkstyle script"

# run gofmt
echo "Run 'gofmt'"
unformatted=$(gofmt -l `pwd`/src/)
if [[ -n $unformatted ]]; then
echo >&2 "Error: Found files not formatted by gofmt"
for fi in $unformatted; do
echo >&2 $fi
done
echo "Please run 'gofmt -w' for files listed."
exit 1
fi

# run goimports
echo "Try update 'goimports'"
GOPATH=`pwd`/Tools go get golang.org/x/tools/cmd/goimports

echo "Run 'goimports'"
unformatted=$(Tools/bin/goimports -l `pwd`/src/)
if [[ -n $unformatted ]]; then
echo >&2 "Error: Found files not formatted by goimports"
for f in $unformatted; do
echo >&2 $f
done
echo "Please run 'goimports -w' for files listed."
exit 1
fi

echo "Run 'go vet'"
ln -s `pwd` `pwd`/vendor/src/github.com/aws/SSMCLI
go vet ./src/...
38 changes: 38 additions & 0 deletions Tools/src/create_darwin_bundle_plugin.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env bash
echo "**********************************************"
echo "Creating bundle zip file Mac OS X amd64 Plugin"
echo "**********************************************"

rm -rf ${GO_SPACE}/bin/darwin_amd64_plugin/sessionmanager-bundle

echo "Creating bundle workspace"

mkdir -p ${GO_SPACE}/bin/darwin_amd64_plugin/sessionmanager-bundle/bin

echo "Copying application files"

cp ${GO_SPACE}/LICENSE ${GO_SPACE}/bin/darwin_amd64_plugin/sessionmanager-bundle/LICENSE
cp ${GO_SPACE}/NOTICE ${GO_SPACE}/bin/darwin_amd64_plugin/sessionmanager-bundle/NOTICE
cp ${GO_SPACE}/THIRD-PARTY ${GO_SPACE}/bin/darwin_amd64_plugin/sessionmanager-bundle/THIRD-PARTY
cp ${GO_SPACE}/README.md ${GO_SPACE}/bin/darwin_amd64_plugin/sessionmanager-bundle/README.md
cp ${GO_SPACE}/RELEASENOTES.md ${GO_SPACE}/bin/darwin_amd64_plugin/sessionmanager-bundle/RELEASENOTES.md
cp ${GO_SPACE}/VERSION ${GO_SPACE}/bin/darwin_amd64_plugin/sessionmanager-bundle/VERSION
cp ${GO_SPACE}/bin/darwin_amd64_plugin/session-manager-plugin ${GO_SPACE}/bin/darwin_amd64_plugin/sessionmanager-bundle/bin/session-manager-plugin
cp ${GO_SPACE}/seelog_unix.xml ${GO_SPACE}/bin/darwin_amd64_plugin/sessionmanager-bundle/seelog.xml.template

echo "Copying install script"

cp ${GO_SPACE}/Tools/src/darwin/install ${GO_SPACE}/bin/darwin_amd64_plugin/sessionmanager-bundle/install
chmod 755 ${GO_SPACE}/bin/darwin_amd64_plugin/sessionmanager-bundle/install;

cd ${GO_SPACE}/bin/darwin_amd64_plugin/sessionmanager-bundle/bin/; strip --strip-unneeded session-manager-plugin; cd ~-

echo "Creating the bundle zip file"

if [ -f ${GO_SPACE}/bin/darwin_amd64_plugin/sessionmanager-bundle.zip ]
then
rm ${GO_SPACE}/bin/darwin_amd64_plugin/sessionmanager-bundle.zip
fi

cd ${GO_SPACE}/bin/darwin_amd64_plugin;
zip -r ${GO_SPACE}/bin/darwin_amd64_plugin/sessionmanager-bundle.zip ./sessionmanager-bundle
Loading

0 comments on commit 65933d1

Please sign in to comment.