-
Notifications
You must be signed in to change notification settings - Fork 177
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
connect failed if no "hostname" in sshconfig #142
Comments
Anyone able to fix this? |
@kadefor You're correct that ssh falls back on a valid Host if HostName is omitted when reading from an .ssh/config file. IMO this logic should exist in mikkeloscar/sshconfig. But this is an easy enough fix I'll submit a PR. |
I'm thinking about it too :-) @mfridman
and
now, we get two username "tom" and "roy"
can we set @VojtechVitek |
@kadefor Yep, looks like it's a bug, the network.Hosts are being overwritten with So for now it'd make sense to do the following: Once Sup supports per host configs, can open it up. for i, host := range network.Hosts {
if conf, ok := confMap[host]; ok {
// attempt fallback on Host definition when HostName is omitted
if conf.HostName == "" {
conf.HostName = host
}
// no point setting the below until Sup supports per host configuration
// network.User = conf.User
// network.IdentityFile = resolvePath(conf.IdentityFile)
network.Hosts[i] = fmt.Sprintf("%s:%d", conf.HostName, conf.Port)
}
} |
I also think we can add "TODO" here. When Sup supports per host config, then refactor :-) |
@kadefor Looking a bit more at the code you could do the following to fix your use case of username/hostname/port like so.. Because the for i, host := range network.Hosts {
if conf, ok := confMap[host]; ok {
// attempt fallback on Host definition when HostName is omitted
if conf.HostName == "" {
conf.HostName = host
}
if conf.User == "" {
conf.User = network.User
}
// no point setting the below until Sup supports per host configuration
// network.User = conf.User
// network.IdentityFile = resolvePath(conf.IdentityFile)
network.Hosts[i] = fmt.Sprintf("%s@%s:%d", conf.User, conf.HostName, conf.Port)
}
} This will return |
@mfridman I'll try to send a PR to support per host config, if I can handle it :-D |
No problem, I'll close my PR. Ideally your PR will address the immediate issue with setting the correct user, hostname and port when reading from a .ssh/config file. |
It would be nice if |
connecting to clients failed: connecting to remote host failed: Connect("root@:22"): ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
The text was updated successfully, but these errors were encountered: