Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Allow ssh key override #87

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

aelsabbahy
Copy link

Implement the "easy" solution requested in #86.

This adds two features:

  • Allow the user to override ssh-key on a per network basis in Supfile
  • Allow the user to override the ssh-key on the command line by using the -i flag

@VojtechVitek
Copy link
Collaborator

@aelsabbahy well done, this is a very good contribution! Thank you. Just a couple of naming nits and we can merge this..

@@ -22,6 +22,7 @@ Stack Up is a simple deployment tool that performs given set of commands on mult
| Option | Description |
|-------------------|----------------------------------|
| `-f Supfile` | Custom path to Supfile |
| `-i`, `sshKey` | Set the the ssh key to use |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They call it identity_file in ssh command. I'm thinking if we should be consistent with them.

@aelsabbahy
Copy link
Author

Want it just changed in the docs or do you want the variable to also be renamed in the code?

Also, I take it networks: section should also have it renamed as identity-file?

@@ -26,6 +26,7 @@ type Network struct {
Env EnvList `yaml:"env"`
Inventory string `yaml:"inventory"`
Hosts []string `yaml:"hosts"`
SSHKey string `yaml:"ssh-key"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're trying to avoid dashes and underscores in the Supfile API. Can we think of one word here?

identity ... or sshkey ... any other suggestions?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IdentityFile is more verbose, but would match 1-1 with ~/.ssh/config syntax, thoughts?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@VojtechVitek VojtechVitek changed the title Allow ssh key override [WIP] Allow ssh key override Jul 26, 2016
@aelsabbahy
Copy link
Author

Sorry for the delay on my end.. been pretty busy and going on vacation.. I'll pick this back up in a few weeks.

@VojtechVitek
Copy link
Collaborator

@aelsabbahy no worries, thanks a lot!

@VojtechVitek
Copy link
Collaborator

Anyone wants to finish this PR based on the above comments?

btw: Related PR: #123

@kadefor
Copy link

kadefor commented Jun 12, 2018

@VojtechVitek Could I send a new PR to finish it (based on the PR and above comments)?

Currently, I want to add some features (#128):

  • parse some host info (from Networks-Host string) using net/url, the string like this:
    ssh://username:password@hostname:port//path/to/ssh/key?KEY=value&KEY=value

    eg: ssh://tom:123@[email protected]:22//home/tom/.ssh/abc.key?MYSQL_HOST=127.0.0.1&MYSQL_PORT=3306

    we can get some info from it:

    1. ssh username: tom
    2. ssh password: 123@456
    3. ssh host: 192.168.16.10
    4. ssh port: 22
    5. ssh host+port: 192.168.16.10:22
    6. ssh identity file: /home/tom/.ssh/abc.key or ~/.ssh/abc.key
    7. some shell variables(per host per host env vars #111): MYSQL_HOST=127.0.0.1 and MYSQL_PORT=3306

    we can add a flag like --use-unsecure-password to enable the password feature

  • update the package golang.org/x/crypto/ssh

  • (Maybe) use flag -i to set (or add?) identity file

Could you give some advice? thank you!

@VojtechVitek
Copy link
Collaborator

VojtechVitek commented Jun 12, 2018

@kadefor would be great if you could split it into separate PRs :) Thanks!

@mfridman
Copy link

@kadefor Just a heads up if considering updating the /x/crypto/ssh package.

In 2017 the Go team made a breaking change to ssh.ClientConfig. (tl;dr, must explicitly specify ssh.HostKeyCallback)

https://go-review.googlesource.com/c/crypto/+/38701

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants