Skip to content

cephadm: Allow users to provide ssh keys during bootstrap#35195

Merged
sebastian-philipp merged 2 commits intoceph:masterfrom
ricardoasmarques:allow-specify-ssh
May 27, 2020
Merged

cephadm: Allow users to provide ssh keys during bootstrap#35195
sebastian-philipp merged 2 commits intoceph:masterfrom
ricardoasmarques:allow-specify-ssh

Conversation

@ricardoasmarques
Copy link
Contributor

@ricardoasmarques ricardoasmarques commented May 22, 2020

With this PR user will be able to provide their own SSH keys:

ceph cephadm set-priv-key -i /root/.ssh/secret
ceph cephadm set-pub-key -i /root/.ssh/secret.pub

Even for the bootstrap:

cephadm boostrap \
    ...
    --ssh-private-key /root/.ssh/secret \
    --ssh-public-key /root/.ssh/secret.pub

Fixes: https://tracker.ceph.com/issues/45629

Signed-off-by: Ricardo Marques rimarques@suse.com

Checklist

  • References tracker ticket
  • Updates documentation if necessary
  • Includes tests for new functionality or reproducer for bug

Show available Jenkins commands
  • jenkins retest this please
  • jenkins test classic perf
  • jenkins test crimson perf
  • jenkins test signed
  • jenkins test make check
  • jenkins test make check arm64
  • jenkins test submodules
  • jenkins test dashboard
  • jenkins test dashboard backend
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox

@ricardoasmarques
Copy link
Contributor Author

ricardoasmarques commented May 22, 2020

@sebastian-philipp Can we assume that cephadm only works with keys that are not protected with passwords?

If yes, then we can have a single command ceph cephadm set-key <private_key> and extract the public key from the private key by doing something like ssh-keygen -y -f <private_key> internally.

Or maybe it's better to explicitly set both anyway, thoughts?

Comment on lines +2567 to +2569
mounts = {}
mounts[pathify(args.ssh_private_key)] = '/tmp/cephadm-ssh-key:z'
mounts[pathify(args.ssh_public_key)] = '/tmp/cephadm-ssh-key.pub:z'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mounts = {}
mounts[pathify(args.ssh_private_key)] = '/tmp/cephadm-ssh-key:z'
mounts[pathify(args.ssh_public_key)] = '/tmp/cephadm-ssh-key.pub:z'
mounts = {
pathify(args.ssh_private_key): '/tmp/cephadm-ssh-key:z'
pathify(args.ssh_public_key): '/tmp/cephadm-ssh-key.pub:z'
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines +4475 to +4494
parser_bootstrap.add_argument(
'--ssh-private-key',
help='SSH private key')
parser_bootstrap.add_argument(
'--ssh-public-key',
help='SSH public key')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Suggested change
parser_bootstrap.add_argument(
'--ssh-private-key',
help='SSH private key')
parser_bootstrap.add_argument(
'--ssh-public-key',
help='SSH public key')
parser_bootstrap.add_argument(
'--ssh-private-key',
type=argparse.FileType('r'),
help='SSH private key')
parser_bootstrap.add_argument(
'--ssh-public-key',
type=argparse.FileType('r'),
help='SSH public key')

FileType also checks whether the file exists, is readable and can be opened, and opens these files, so the filename will be stored in args.ssh_*_key.name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

def _set_priv_key(self, inbuf=None):
if inbuf is None or len(inbuf) == 0:
return -errno.EINVAL, "", "empty private ssh key provided"
self.set_store("ssh_identity_key", inbuf)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any plan to remediate this? Storing private SSH keys in the clear (Is this somehow printed to the logs? Is this mon key-value store encrypted?) sounds like a serious attack vector: Dashboard's CVE-2020-1699 (or any other user-facing component breach) would expose the filesystem under ceph user, but with this data there everything else would be compromised, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@epuertat AFAIK, it's not possible to encrypt "config-keys". Note that this security issue is not being introduced in this PR, it's already present for the "generated SSH key" - https://github.com/ceph/ceph/blob/master/src/pybind/mgr/cephadm/module.py#L745

@sebastian-philipp was this security issue already discussed? Should we have a separate issue for that?

FYI, a similar discussion happened here ceph/ceph-iscsi#173 (comment)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the context, @ricardoasmarques!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, we need a proper and secure way to store secrets in the MONs. config-key and config are both not designed to store passwords etc. @jecluis any opinion? @travisn maybe something in the direction of k8s secrets might be an idea?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sebastian-philipp Rook certainly relies on K8s secrets, but not sure how cephadm could leverage something similar.

@sebastian-philipp
Copy link
Contributor

can we also set the ssh config?

Copy link
Member

@epuertat epuertat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing my comments @ricardoasmarques !

@ricardoasmarques
Copy link
Contributor Author

can we also set the ssh config?

@sebastian-philipp I've pushed a new commit that will alow users to provide ssh config during bootstrap (--ssh-config option).

@sebastian-philipp
Copy link
Contributor

Big thanks! Do you also want to amend the man page? https://docs.ceph.com/docs/master/man/8/cephadm/

Custom ssh config can be provided by using the '--ssh-config' option

Signed-off-by: Ricardo Marques <rimarques@suse.com>
@ricardoasmarques
Copy link
Contributor Author

Big thanks! Do you also want to amend the man page? https://docs.ceph.com/docs/master/man/8/cephadm/

@sebastian-philipp Good catch. Man page is now updated.

@sebastian-philipp sebastian-philipp added the wip-swagner-testing My Teuthology tests label May 27, 2020
@sebastian-philipp
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants