An open API service indexing awesome lists of open source software.

https://github.com/vinc/closh

🖥️ Get a shell running in the cloud in seconds
https://github.com/vinc/closh

cloud shell

Last synced: 2 months ago
JSON representation

🖥️ Get a shell running in the cloud in seconds

Awesome Lists containing this project

README

          

Cloud Shell
===========

[![Gem](https://img.shields.io/gem/v/closh.svg)](https://rubygems.org/gems/closh)
[![Travis branch](https://img.shields.io/travis/vinc/closh/master.svg)](https://travis-ci.org/vinc/closh/branches)
[![Gemnasium](https://img.shields.io/gemnasium/vinc/closh.svg)](https://gemnasium.com/github.com/vinc/closh)

Get a shell running in the cloud in seconds

[![asciicast](https://asciinema.org/a/146126.png)](https://asciinema.org/a/146126)

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

$ gem install closh

Alternatively you can build the gem from its repository:

$ git clone git://github.com/vinc/closh.git
$ cd closh
$ gem build closh.gemspec
$ gem install closh-0.0.1.gem

Usage
-----

Run a command in the cloud:

$ closh -x "cut -d . -f 1 /proc/uptime"
23

More verbose:

$ closh -vx "cut -d . -f 1 /proc/uptime"
debug: uploading SSH public key to AWS ...
debug: creating server on AWS ...
debug: connecting to 'ubuntu@158.116.77.89' ...
debug: executing command 'cut -d . -f 1 /proc/uptime' ...
23
debug: destroying server ...

Pipe to stdin:

$ echo "cut -d . -f 1 /proc/uptime" | closh -x "bash -s"

Run a script remotely:

$ closh -x "bash -s" < example.sh

Skip the `-x` flag to keep a session alive for long running scripts.

Use `-l` to list sessions and `-r` to resume one:

$ closh -r 158.116.77.89 "tail -f screenlog.0"

More options:

$ closh -h
Usage: closh

Cloud Shell v0.0.1
Options:
-n, --dry-run Create fake server and run locally
-c, --config= Config file (default: ~/.closh.yml)
-k, --key= SSH public key (default: ~/.ssh/id_rsa.pub)
-r, --resume= Resume session
-x, --kill Kill session at the end
-l, --list List sessions
-v, --verbose Use verbose mode
-h, --help Show this message
-V, --version Print version and exit

Configure
---------

Cloud Shell is based on [Fog](http://fog.io/) under the hood to create compute
servers.

The configuration is stored in a YAML file (`~/.closh.yml`). It is divided in
two parts: compute and server. The former being fed to `Fog::Compute.new` and
the latter to `Fog::Compute::*::Server.new`.

```yaml
---

compute:
provider: AWS
aws_access_key_id: <%= ENV["AWS_ACCESS_KEY_ID"] %>
aws_secret_access_key: <%= ENV["AWS_SECRET_ACCESS_KEY"] %>
region: us-east-1

server:
image_id: ami-b04847cf # Ubuntu 18.04 LTS
flavor_id: t2.micro
username: ubuntu
groups:
- default
- ssh
```

License
-------

Copyright (c) 2017-2018 Vincent Ollivier. Released under MIT.