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

Is this possible with assh? #100

Closed
ashmatadeen opened this issue Jan 29, 2016 · 12 comments
Closed

Is this possible with assh? #100

ashmatadeen opened this issue Jan 29, 2016 · 12 comments
Assignees
Labels

Comments

@ashmatadeen
Copy link
Contributor

I would like to set up my ssh config to connect to a number of servers:

  • server1.domain.com
  • server2.domain.com
  • server3.domain.com
  • server4.domain.com
    etc

by simply doing
ssh server[X]

Connection to all servers are with the same ssh key and same user.
Is this possible with assh?

I have tried this:

  hosts: 
    "server*":
      Hostname: "%h.domain.com"
      User: ash
      IdentityFile: ~/.ssh/id_ecdsa

which errors with:
FATA[0000] Proxy error: dial tcp [::1]:22: getsockopt: connection refused

Thanks,
Ash

@moul moul added the Question label Feb 1, 2016
@moul moul self-assigned this Feb 1, 2016
@moul
Copy link
Owner

moul commented Feb 1, 2016

Hi @ashmatadeen,

Your configuration should works, however, there is a bug, I'm resolving twice the %h format string


example:

Using your configuration file:

$ ssh -v server1
[...]
debug1: Executing proxy command: exec assh proxy --port=22 server1.domain.com
[...]
time="2016-02-02T00:09:47+01:00" level=info msg="Host server1.domain.com"
time="2016-02-02T00:09:47+01:00" level=info msg="  HostName server1.domain.com.domain.com"
time="2016-02-02T00:09:47+01:00" level=info msg="  IdentityFile ~/.ssh/id_ecdsa"
time="2016-02-02T00:09:47+01:00" level=info msg="  User ash"

@moul moul added Bug and removed Question labels Feb 1, 2016
@moul
Copy link
Owner

moul commented Feb 1, 2016

As a temporary fix, you can use this:

  "server*":
    #Hostname: "%h.domain.com"
    ResolveCommand: "echo %h.domain.com"
    User: ash
    IdentityFile: ~/.ssh/id_ecdsa

@ashmatadeen
Copy link
Contributor Author

Thanks @moul

@moul
Copy link
Owner

moul commented Feb 3, 2016

I just pushed a fix (see #103, c403cf4)

Can you rebuild assh and give a new try ?

@moul
Copy link
Owner

moul commented Feb 3, 2016

I also made a new release: https://github.com/moul/advanced-ssh-config/releases/tag/v2.2.0 so you can fetch the artifacts as you did the first time

@ashmatadeen
Copy link
Contributor Author

That worked @moul Thanks for the fix.

One more thing though, is this expected output when running assh proxy localhost
~/.ssh > assh proxy localhost FATA[0000] Proxy error: dial tcp [::1]:22: getsockopt: connection refused

@moul
Copy link
Owner

moul commented Feb 3, 2016

Cool !


Is the output like this:

~/.ssh > assh proxy localhost FATA[0000] Proxy error: dial tcp [::1]:22: getsockopt: connection refused

Or like this:

~/.ssh > assh proxy localhost
FATA[0000] Proxy error: dial tcp [::1]:22: getsockopt: connection refused

?


In the first case, I think this is an old message, probably an old SSH connection that stayed open thanks to ControlMaster SSH support

In the second case, it looks normal ! However, the error messages can be improved to be more human-readable :) any advices ?

@ashmatadeen
Copy link
Contributor Author

It's the second one. The config file gets generated successfully and works as expected despite the error. I'm not clear on what the proxy error means though.

@moul
Copy link
Owner

moul commented Feb 3, 2016

The assh proxy command will:

  1. parse ~/.ssh/assh.yml file
  2. write ~/.ssh/config file
  3. open a network connection unless you use the --dry-run option

I didn't split 1. and 2. into two actions, so in the ~/.ssh/config file you can find an entry ProxyCommand assh proxy ..., which will do all the stuff at once

This error is not related with 1. and 2. but with 3., which here indicates that 127.0.0.1:22 is closed


Give a try to these commands:

  • assh proxy --dry-run localhost
  • assh -D proxy localhost

@ashmatadeen
Copy link
Contributor Author

That makes more sense now.

If the use case is to only generate the config file, maybe the command in step 3 under Getting started could be assh build > ~/.ssh/config instead?

@moul
Copy link
Owner

moul commented Feb 4, 2016

Yep, definitely ! Do you want to make the change ? :)

@moul
Copy link
Owner

moul commented Feb 4, 2016

Closing this issue as it was already addressed, do not hesitate to reopen it or open a new one if necessary

Thanks again for your help

@moul moul closed this as completed Feb 4, 2016
AshishPandeyaid pushed a commit to AshishPandeyaid/assh that referenced this issue Dec 26, 2022
run `assh build > ~/.ssh/config` instead of `assh proxy localhost` to generate config file. Please see #100 moul/assh#100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants