Score:0

Linux: Is it possible to use the ssh key pair instead or in addition to the root privileges?

id flag

I'm facing the problem of securing an embedded platform. All ssh hardening have been setup, including 2 factor authentication and login with ssh key pairs.

Now, the root and user passwords are ridiculous easy to crack, all you need is physical access to the device, leaving all measures and precautions redundant. My idea is to harden the root access with the same techniques as ssh.(hardening the sudo command and root access) However while it is a common problem across all embedded platforms, I can't find much information on this.

How do I tackle this?

John Mahowald avatar
cn flag
Your question seems to have a little bit of an XY problem. The title is how to use a ssh key relating to how you know to secure ssh, when you really seem to be after defense against physical access, or at least not-ssh logins.
Whois_me avatar
id flag
No, not really. The question still stands. I know the sudo password can be easily hacked, I've done it myself the other day. Therefore I'm thinking about some authentication based on the ssh public keypair in addition to sudo and root password after a successful secure shell login. Most admins want to omit the sudo password altogether while they login but I think the original root authentication scheme is a bit outdated.
Score:1
fr flag

I am not sure what exactly you are asking for so I'll take a guess and assume that you want to harden your sudo authentication.

If this is the case and sudo on your system supports PAM then have a look at pam_ssh_agent_auth for ssh public key authentication or at pam_sss_gss (which may require properly setup FreeIPA IdM).

Whois_me avatar
id flag
Thank you @ Tomek. Yes that is exactly what i'm after. Hardening the sudo command.
Score:0
cn flag

Physical access cannot be completely defended. A sufficiently motivated person will reverse engineer the system to get access, up to disassembling it and reading off the hardware.

Make an attacker's task more difficult by replacing passwords with stronger authentication where possible.

SSH can be configured to remove password auth, both OpenSSH and dropbear implementations allow this.

Review what logins are possible locally, not over the network. Video out with USB in may enable login to a tty. Or, the hardware may provide a serial console.

On a Linux box with PAM libraries, authentication is customizable, via modules that can be combined in various ways.

  • Allow for login or sudo U2F with hardware authenticators like Yubikey (pam_u2f)

  • Allow one time password from a device (pam_google_authenticator or pam_oath)

  • Authenticate based on ssh-agent (pam_ssh_agent_auth)

  • Remove passwords as sufficient for authentication

  • Prohibit root login, only allow root to a difficult to physically access serial port (pam_securetty)

  • If you must have passwords, enforce a long length like 16 characters (pam_pwquality) and encourage use of phrases like with Diceware. Do not use "complexity" requirements, those are not user friendly.

That is an introduction to OS authentication, what about before? During boot is an example where physical access gets you in. Editing the kernel command in grub can get you a shell without credentials. Which while useful to recover from lost credentials, may not be desirable. Consider password protecting the boot loader.

Whois_me avatar
id flag
Thank you @john or this answer, Onboard the platform is indeed an option to encrypt the uboot bootloader's partition. That's my next move coming from ssh sudo hardening.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.