Hi all openssh devs out there. I have quite a few Host-stanzas in my .ssh/config to keep track of all the different settings and credentials needed to access all different hosts I connect to. Now I have ran in to a problem where I need to switch settings based on what user I'm trying to login to a host as. A simple case is: ssh -i rootkey root at host123 vs. ssh -i userkey username at host123 Up until now I have just used a stanza like Host host123 User username IdentityFile userkey But it would be awesome of it was possible to add before that, eg fist match as all other blocks, a stanza looking like: Host root at host123 IdentityFile rootkey So when I type: "ssh host123" it resolves to equivalent of "ssh -i userkey username at host123" And when i type: "ssh root at host123" it would resolve to "ssh -i rootkey root at host123" Does this sound reasonable to the rest of you? //Anton Ps. Please keep me on Cc, I'm not subscribed to the list. -- Anton Lundin +46702-161604
Hi, Why not just do : Host rhost123 User root IdentityFile rootkey Host uhost123 User user IdentityFile userkey Why not just do : Flavien. Anton Lundin ecrivait :> Hi all openssh devs out there. > > I have quite a few Host-stanzas in my .ssh/config to keep track of all the > different settings and credentials needed to access all different hosts I > connect to. > > Now I have ran in to a problem where I need to switch settings based on what > user I'm trying to login to a host as. A simple case is: > > ssh -i rootkey root at host123 > vs. > ssh -i userkey username at host123 > > Up until now I have just used a stanza like > > Host host123 > User username > IdentityFile userkey > > But it would be awesome of it was possible to add before that, eg fist > match as all other blocks, a stanza looking like: > > Host root at host123 > IdentityFile rootkey > > > So when I type: > "ssh host123" it resolves to equivalent of "ssh -i userkey username at host123" > And when i type: > "ssh root at host123" it would resolve to "ssh -i rootkey root at host123" > > > Does this sound reasonable to the rest of you? > > //Anton > > Ps. > Please keep me on Cc, I'm not subscribed to the list. > > -- > Anton Lundin +46702-161604 > _______________________________________________ > openssh-unix-dev mailing list > openssh-unix-dev at mindrot.org > https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev--
On Tue, Jun 18, 2013 at 05:33:16 -0500, Anton Lundin wrote:> Hi all openssh devs out there. > > I have quite a few Host-stanzas in my .ssh/config to keep track of all the > different settings and credentials needed to access all different hosts I > connect to. > > Now I have ran in to a problem where I need to switch settings based on what > user I'm trying to login to a host as. A simple case is: > > ssh -i rootkey root at host123 > vs. > ssh -i userkey username at host123 > > Up until now I have just used a stanza like > > Host host123 > User username > IdentityFile userkey > > But it would be awesome of it was possible to add before that, eg fist > match as all other blocks, a stanza looking like: > > Host root at host123 > IdentityFile rootkey > > > So when I type: > "ssh host123" it resolves to equivalent of "ssh -i userkey username at host123" > And when i type: > "ssh root at host123" it would resolve to "ssh -i rootkey root at host123" > > > Does this sound reasonable to the rest of you? > > //Anton > > Ps. > Please keep me on Cc, I'm not subscribed to the list. >What about using %r when you specify IdentityFile? -- Iain Morgan
On Tue, 18 Jun 2013, Anton Lundin wrote:> But it would be awesome of it was possible to add before that, eg fist > match as all other blocks, a stanza looking like: > > Host root at host123 > IdentityFile rootkeyI floated the idea recently with Darren of introducing Match for ssh_config: Match user djm host evil.com IdentityFile foo I'll try to implement this for 6.3 if I get time and nobody beats me to it. It's pretty easy if anyone wants to have a go at it - most of the infrastructure already exists for the "Host" directive. -d