pressly / sup

Super simple deployment tool - think of it like 'make' for a network of servers
https://pressly.github.io/sup
MIT License
2.48k stars 178 forks source link

Use ~/.ssh/config or allow user to override key #86

Open aelsabbahy opened 8 years ago

aelsabbahy commented 8 years ago

Awesome project!

Currently it seems ssh key is hardcoded to ~/.ssh/id_rsa or ~/.ssh/id_dsa.

tpaz commented 8 years ago

Or use ssh-agent, so if you have configured your keys to be cached by ssh-add, theoretically it should work... at least in code there was preparation for that: // If there's a running SSH Agent, try to use its Private keys. sock, err := net.Dial("unix", os.Getenv("SSH_AUTHSOCK")) if err == nil { agent := agent.NewClient(sock) signers, = agent.Signers() }

Not sure it works, didn't for me. I had the same problem, eventually I simply dedicated a different User to use sup to work-around it :)

aelsabbahy commented 8 years ago

I think ssh-agent worked for me when I tried it.

Honoring .ssh/config allows for more complex things like setting the user.

VojtechVitek commented 8 years ago

ssh-agent works, as long as $SSH_AUTH_SOCK env var is set correctly

otherwise, sup defaults to ~/.ssh/id_rsa and ~/.ssh/id_dsa --- we might want to parse more files from ~/.ssh directory (ssh does this by default)

VojtechVitek commented 8 years ago

Parsing ~/.ssh/config is also doable - but personally, I don't have time for it. Feel free to take over and send us a PR :)

tpaz commented 8 years ago

+1 worked for me with ssh-agent as described above, eventually :) to add config file support - I will first have to gain more experience in Go :)

guitmz commented 7 years ago

is this going to happen? :)

jakewarren commented 7 years ago

I opened a Bountysource bounty if anyone wants to take it on. :)

Bounty

pxue commented 7 years ago

@jakewarren I have a starter solution to parse / honour ~/.ssh/config in https://github.com/pressly/sup/pull/105 . shouldn't be too much of an extension to handle different keys as well

VojtechVitek commented 7 years ago

@pxue pls let me know if you want to add it to #105. I'll try my best to finally finish the review after it's done. (Sorry for the delay!)

juergenhoetzel commented 6 years ago

I suspect the global auth initialization code:

var initAuthMethodOnce sync.Once
var authMethod ssh.AuthMethod

must be changed to something like:

var authMethod map[string]ssh.AuthMethod

Do allow per-network configuration of keys?

I would prefer to specify the keys in the supfile instead of parsing the openssh configfile because I prefer to have the config in one place. I also think it is not feasible to map the openssh CertificateFile to sups networks in a consistent way.

I my pull request https://github.com/juergenhoetzel/sup/commit/74b4a4b193c0f8cc3db1bb5b85fc981bdedfbb41 I have relaxed the search for SSH-Keys: Use of id_" wildcard.

VojtechVitek commented 6 years ago

FYI, #123 has been just merged. Sup now loads any private key matching ~/.ssh/id_* wildcard.

VojtechVitek commented 6 years ago

105 and #124 were merged too.

The only remaining part is actually using the custom IdentityFile. It doesn't work yet.

untoreh commented 6 years ago

I think comments (#) if the config ends with a comment and lines ending with whitespace in the ssh config file make sup hang

ah sup hangs because doesn't expect a host to have multiple aliases, which might be the case if using ~/.ssh. The parser lib also doesn't trim whitespace from the Port field, that should at least do since the port is always single Although sup also hangs when the last line in the config is a comment, have not checked if its related to the parser

untoreh commented 6 years ago

Also when using a config file a run command is actually run only on one host (?) this is weird

mj-ano commented 5 years ago

Yeah, I just figured it out, Is this a bug, not looping through the hosts if it's pulling from SSH Config file

muodov commented 5 years ago

For those who want to use it with custom keys, simple symlink worked for me:

$ cd ~/.ssh
$ ln -s mykey id_mykey
$ ln -s mykey.pub id_mykey.pub