8
2
I use ssh on a variety of machines, mainly linux. Accounts on these machines vary in naming scheme: if my name is First Last, then I have accounts: first, flast, last_f, lastf, and sometimes I need to log in as root. For each machine I use, I would like the openssh client to know which account to use when I don't specify on the command line.
So the question is: How do I make ssh server
Do The Right Thing when a username is not specified?
i assume you can specify another user/host pair later in the file?
Host example2/HostName example2.com/User last_first
and such? – quack quixote – 2009-11-03T14:03:49.780Of course!!!!!!!!!!!!!!!!!! – innaM – 2009-11-03T14:06:18.683
3Absolutely, you can specify as many as you want in the same .config file. I have over 20 in mine with no issues. I just leave a space between each distinct Host, which probably isn't required, but makes it more readable. – Rich Adams – 2009-11-03T14:06:40.057
1Shouldn't it be
config
file? Without dot at the beginning? – danadam – 2009-11-03T14:21:45.770@danadam : Yes, you're correct. I've updated the answer accordingly. Thanks. – Rich Adams – 2009-11-03T14:24:19.790
1@rich was trying to get you to show another site in your example; hope you don't mind me going ahead and throwing it in. – quack quixote – 2009-11-03T14:57:40.003
4Indenting everything but lines that contain "Host foo" greatly helps the maintainability cause. – innaM – 2009-11-03T16:42:31.290
1@CristianCiupitu: Considering the is a Linux question, I'd hardly call the OpenBSD's man page the official one. There are options in Linux's ssh (e.g., GSSAPIKeyExchange) that aren't available in the BSD version. – Dennis – 2014-03-30T15:15:03.400
@Dennis, you're right about GSSAPIKeyExchange not being available in the OpenBSD version, but it seems to be provided by a patch, so it's not in the portable version either. For example FreeBSD 10 doesn't have it.
– Cristian Ciupitu – 2014-03-30T16:23:31.860@CristianCiupitu: That's another BSD version. It only results in minor differences here (noneof them relevant to the question), but using BSD man pages for Linux distros (and vice versa) is generally a bad idea. For example, the syntaxes of the BSD and Linux flavors stat are completely different.
– Dennis – 2014-03-30T16:40:36.870@Dennis, all the other BSDs use the portable version too. Heck, there's even a Linux man page that doesn't mention GSSAPIKeyExchange. I agree about being careful about mixing BSD man page with Linux ones.
– Cristian Ciupitu – 2014-03-30T16:47:57.517