I have the following in my ~/.ssh/config.
HOST 10.2.192.*
USER foo
PreferredAuthentications publickey
IdentityFile ~/.ssh/foo/id_rsa
The above configuration lets me connect to a machine while typing half as many words.
ssh 10.2.192.x
Before my ssh config, I had to type in all of this:
ssh <a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="4a2c25250a7b7a6478647b73786432">[email protected]</a> -i ~/.ss/foo/id_rsa
However there is one machine in the 10.2.192.x subnet that I want to connect to with password based authentication instead of keybased authentication.
Because ssh looks at my config file and finds a match for PreferredAuthentications publickey I am unable to login with just my password.
I don’t intend to ssh into this special snowflake vm often enough to warrant adding a new rule to my ssh config.
How can I make ssh ignore my config file just this once, and allow me to authenticate with a password?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
To make your ssh client ignore your configuration file, use ssh -F /dev/null [email protected]. Because your subnet’s IdentityFile is in ~/.ssh/foo rather than ~/.ssh/, you don’t need to whip up a whole new file to eschew your extant private key.
From the ssh man page:
-F configfile
Specifies an alternative per-user configuration file. If a
configuration file is given on the command line, the system-wide
configuration file (/etc/ssh/ssh_config) will be ignored. The default
for the per-user configuration file is ~/.ssh/config.
Method 2
I believe that this question is already answered by: How to force ssh client to use only password auth?
ssh -o PubkeyAuthentication=no example.com
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0