mirror of
https://github.com/ovh/the-bastion.git
synced 2026-05-09 08:25:27 +02:00
[GH-ISSUE #101] Password authentication for egress connections #23
Labels
No labels
answered
bug
documentation
enhancement
enhancement
feature
feature
kept-open-for-info
pull-request
question
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/the-bastion#23
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @dwydler on GitHub (Dec 17, 2020).
Original GitHub issue: https://github.com/ovh/the-bastion/issues/101
Hallo everyone,
we have some old switches in our network, which do not support public key authentication. So any it admin had a own account with a custom password.
I study the docs and found in
/etc/bastion/bastion.confa parameterpasswordAllowed. According to the description exactly what i am looking for.I change the value from
0to1. After that i connected to a fresh bastion session and try different commands to get a prompt for password authentication.Is the parameter even suitable for my requirements?
If so, which parameters do I have to use with the command
ssh admin@host: 22?Regards,
Daniel
@speed47 commented on GitHub (Dec 18, 2020):
Hello,
We do have a few of those too. That's what
passwordAllowedis for, indeed, among other things.The documentation about how to handle this case properly is missing, but I guess this means I'll have to write it faster than I though previously :)
I'll try to sum up here: you have 2 possible solutions.
Just let the people type their passwords themselves when the remote device prompts it. In that case, setting
passwordAllowedto 1 should be enough. Note that some network devices don't actually use password auth but keyboard-interactive auth. In both cases you're prompted with a passwword, but the SSH auth method is slightly different underneath. In that case, you would need to setkeyboardInteractiveAllowedto 1 also. In that case, the bastion doesn't handle the egress auth side: the user does.Let the bastion type the password to the remote device. In that case, you still need to enable passwordAllowed and/or keyboardInteractiveAllowed, but you can use the
selfGeneratePasswordcommand. The bastion will generate a random password, with the complexity you specify, and give you back the password hash to add to the userline on the remote device. In that case, the bastion user doesn't even know the password: the bastion will type it for them. To tell the bastion to do this, the users will have to use the-Pcommand when connecting to the device through the bastion. What's nice here is that you can use a very complex password of e.g. 32 chars or even more: nobody will ever need to type it manually. You may also want to rotate the passwords every 3 months or so. In that case, this would be transparent to the users: you would just have to generate a new password on the bastion, and update the userline on the device. A proper chapter of the documentation will cover this soon.@dwydler commented on GitHub (Dec 18, 2020):
Hi @speed47
thanks a lot for the detailed description the possibilities. I would like to use scenario 1). Both parameters
passwordAllowedandkeyboardInteractiveAllowedare already set to1already.On every attempt i do not get a password prompt. The Bastion displays a error message like
access denied. Or is the parameter-p(ssh admin@host:22 -Pnecessary here?@speed47 commented on GitHub (Dec 21, 2020):
Can you copy/paste the exact error message? It may contain some clues.
No, if you want interactive prompt,
-Pshould not be used. However if you think your device uses keyboard-interactive authentication, you should add--kbd-interactivewhen wanting to connect to such a device (settingkeyboardInteractiveAllowedjust means that this option can be used, it's not enabled by default for all connections).So for example if your bastion alias is
bastion, you should usebastion --kbd-interactive admin@networkdev.Of course if your users will be connecting to such devices all the time, they can include this command directly in their bastion alias, for example if their alias is:
alias bastion='ssh -t me@mybastion.example.org --'It can be set as:
alias bastion='ssh -t me@mybastion.example.org -- --kbd-interactive'Note the double-dash before the
--kbd-interactive: it tells your localsshcommand not to try to parse this option, but pass it rremotely (to the bastion).If this still doesn't work, and you have shell access to the bastion, can you try these two commands:
ssh -o passwordauthentication=yes -o preferredauthentications=password admin@hostand:
ssh -o kbdinteractiveauthentication=yes -o preferredauthentications=keyboard-interactive admin@host?
@dwydler commented on GitHub (Dec 21, 2020):
Hello,
sure, here the complete output of the (error) message. I connect directly with my user to the bastion.
After your detailed explain i tried it with the parameter --kbd-interactive. But the result is still the same. :-(
The current configuration looks like this:
In a bash shell on the bastion everything works as is should. I type the same command
ssh netadmin@192.168.95.1. send teh command and get few seconds later the prompt to enter the password.@speed47 commented on GitHub (Dec 21, 2020):
OK, in that case the solution is easy:
This is the bastion saying that, as far as it can tell,
myusernameis not allowed to connect on the remote server.In your case, as the users will type their login/passwords themselves, you can just tell the bastion to allow them:
accountAddPersonalAccess --account myusername --host 192.168.0.0/16 --port 22 --user netadminYou'll need to do this as a bastion admin (of course, you can adjust 192.168.0.0/16 accordingly).
If such accesses need to be added automatically for everyone when their account is created, there is a config parameter for this: https://ovh.github.io/the-bastion/administration/bastion_conf.html#bastion-conf-accountcreatedefaultpersonalaccesses
@dwydler commented on GitHub (Dec 21, 2020):
Now that you say it, it sounds logical... now i understand the logic.
Does it (
accountAddPersonalAccess --account myusername --host 192.168.0.0/16 --port 22 --user netadmin) also work when using groups (groupAddServer --group testgroup1 --host 192.168.0.0/16 --port 22 --user netadmin) ?@speed47 commented on GitHub (Dec 21, 2020):
Personal accesses and group accesses are two ways you can use to handle accesses. It depends on use cases, and both can (and often should!) be used on the same bastion, depending on how are handled the infrastructures behind it, and how many users are using the bastion.
If you haven't read it, this blog post tells more about those two ways: https://www.ovh.com/blog/the-ovhcloud-ssh-bastion-part-2-delegation-dizziness/
But to answer your question, yes, you can also add 192.168.0.0/16 to a group, and then grant membership to this group to your users :)
@dwydler commented on GitHub (Dec 22, 2020):
New day, new luck. :-)
First, i created a entry for my users. For that i added the parameter
---force. Otherwise I get an error message:After that i try to connect to a switch in our network. But the connection failed.
Basicly Bastion detected in line 11 all active methods (publickey,keyboard-interactive,password) correct.
What did I miss / do wrong?
@speed47 commented on GitHub (Dec 23, 2020):
Can you check the bastion
/etc/ssh/ssh_configfile?Would need to set:
The bastion's configuration
passwordAllowed,keyboardInteractiveAllowedand--kbd-interactiveonly allow the bastion to puth these auth methods in thePreferredAuthenticationsssh option when connecting to the device, but if the auth method is disabled system-wide through the/etc/ssh/ssh_configfile (which it is, by default), the bastion won't override it!@dwydler commented on GitHub (Dec 23, 2020):
Here my current
/etc/ssh/ssh_configfrom the bastion host:To be on the safe side i restarted the whole server for my test connection. Unfortunately the result still the same:
Do you have any other ideas?
@dwydler commented on GitHub (Dec 23, 2020):
After some cups of coffee i found my fault. I edited /etc/ssh/sshd_config instead of as /etc/ssh/ssh_config - again.
So i have done the changes in the right file. After that i could connect successfully to my our test switches with the custom password.
Many thanks for your support. I wish you Merry Christmas!
P.S. Perhaps you can complete the docs about this chapter. ;-)