Skip to content

Commit

Permalink
Merge pull request #19 from gmacdougall/add-remote-forward
Browse files Browse the repository at this point in the history
Add ability to RemoteForward
  • Loading branch information
cbrunsdon authored Feb 14, 2017
2 parents 3afc5e9 + 03aeb0d commit 510e2ff
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,11 @@ secret = "abcd1234"
```
omc help
```

Accepted ssh options:
```
-R 3000:localhost:3001 # Forwards port 3000 on the remote host to port 3001 on the localhost
-A # Forward agent
```

Please the the ssh help for more detail.
4 changes: 3 additions & 1 deletion lib/omc/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class Cli < Thor
class_option :account, aliases: '-a'
class_option :layer, aliases: '-l'
class_option :forward_agent, aliases: "-A", type: :boolean, default: false
class_option :remote_forward, aliases: "-R", type: :string, default: nil

desc 'ssh STACK', 'Connect to an instance on a stack on an account'
def ssh(stack)
Expand All @@ -17,7 +18,8 @@ def ssh(stack)
user,
stack,
layer: options[:layer],
forward_agent: options[:forward_agent]
forward_agent: options[:forward_agent],
remote_forward: options[:remote_forward]
)
command.ssh
end
Expand Down
10 changes: 8 additions & 2 deletions lib/omc/stack_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@

module Omc
class StackCommand
def initialize aws_account, user, stack_name, app: nil, layer: nil, forward_agent: false
def initialize aws_account, user, stack_name, app: nil, layer: nil, forward_agent: false, remote_forward: nil
@aws_account = aws_account
@user = user
@stack_name = stack_name
@app_name = app
@layer_name = layer
@forward_agent = forward_agent
@remote_forward = remote_forward
end

def ssh
Expand Down Expand Up @@ -100,8 +101,13 @@ def bastion

def default_ssh_args
[].tap do |args|
args.push("-o", "ProxyCommand ssh -W %h:%p #{bastion.host}") if bastion
if (bastion)
proxy_command = "ProxyCommand ssh -W %h:%p #{bastion.host}"
proxy_command += " -R #{@remote_forward}" if @remote_forward
args.push("-o", proxy_command)
end
args.push("-A") if @forward_agent
args.push("-R #{@remote_forward}") if @remote_forward
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/omc/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Omc
VERSION = '0.0.9'
VERSION = '0.0.10'
end

0 comments on commit 510e2ff

Please sign in to comment.