-
Notifications
You must be signed in to change notification settings - Fork 33
How to Add or Remove User SSH Access
- Access to the BFD AWS Account
- IAM permissions to decrypt sensitive SSM parameters
- An installation of the AWS CLI that is configured properly for access to the BFD/CMS AWS account
- An installation of the
ansible
CLI - An installation of the
terraform
CLI- Using a tool like
tfenv
allows for multiple installations of Terraform and automatic version management
- Using a tool like
- Your
EDITOR
environment variable set to a proper editor- You can set this variable in your
.bashrc
(if you're usingbash
) or.zshrc
(if you're usingzsh
) like so:export EDITOR=<your editor executable here>
. Other shells may have a different syntax for setting environment variables or a different configuration file
- You can set this variable in your
- This repository,
beneficiary-fhir-data
, pulled down locally
It is recommended that you read the following
README
s for more information on the SSM configuration scheme used by BFD before continuing:Additionally:
- You will need to know the user's EUA
- You will need the user's SSH public key and desired username
- You will need to know the level of access the user has to each established environment and whether they should be given access by default
-
In your terminal, navigate to the root of your local copy of the
beneficiary-fhir-data
repository usingcd
-
In your terminal, relative to the root of this repository,
cd
to the directory associated with themgmt
Terraform module:cd ops/terraform/env/mgmt
-
Initialize the Terraform state locally:
terraform init
-
Once initialized, view the Terraform plan and verify that Terraform is able to load state for all of the resources managed by the
mgmt
module and that no changes are necessary:terraform plan
-
Navigate into the
base_config
module's directory:cd base_config
-
Ensure you are authenticated with AWS and are able to run AWS CLI commands
-
Open the encrypted yaml
mgmt.yaml
for editing using theedit-yaml.sh
script using the commands below. This will decrypt the encryptedmgmt.yaml
file and open it in your definedEDITOR
. The script will wait until the file is closed by your editor, at which point it will re-encryptmgmt.yaml
with your changes and save itchmod +x scripts/edit-yaml.sh scripts/edit-yaml.sh mgmt
-
You will see many keys grouped together in the format shown below. In the example below,
....
represents each user's EUA ID. Each key represents the following:-
ssh_user
represents the user's SSH username that they will use to connect to a machine using their key -
ssh_public_key
represents the public key component of the user's key-pair. This must be generated by the user themselves and provided to you -
ssh_default_access
defines whether the user has access, by default, to connect via SSH to any BFD instance in any environment. Essentially, this overrides per-environment access for a given user and should be set totrue
for users that require access in all environments (such as those in our on-call rotation) -
ssh_default_sudoer
defines whether the user hassudoer
permission, by default, for any BFD instance in any environment. Essentially, this overrides per-environmentsudoer
access for a given user and should only be set totrue
for users that need access tosudo
in all environments (such as those in our on-call rotation)
/bfd/mgmt/common/sensitive/user/..../ssh_user: "some.username" /bfd/mgmt/common/sensitive/user/..../ssh_public_key: "ssh-key .... identity" /bfd/mgmt/common/sensitive/user/..../ssh_default_access: bool /bfd/mgmt/common/sensitive/user/..../ssh_default_sudoer: bool
-
-
Following the format outlined in step #8, append the new user's
ssh_user
,ssh_public_key
,ssh_default_access
, andssh_default_sudoer
values (depending on their required level of access) to the end of the block associated with SSH. Remember, you will need the user's EUA as it is part of the SSM parameter's path -
Close the file. This should immediately update the encrypted
mgmt.yaml
with your new changes -
Return to the
mgmt
module:cd ..
-
Plan the changes to the Terraform state and verify that there are only additions to the state and that these additions correspond to the new SSH SSM parameters defined in step #9:
terraform plan
-
Now that the user's username and SSH public key are set in the
mgmt
environment, the user's SSH access andsudoer
access can be defined per-environment. If the user has been given default access to SSH and to usesudo
then steps #14 through #22 can be skipped as the user does not need to be configured in our established environments -
From the root of the repository, navigate to the
base
Terraform service module:cd ops/terraform/services/base
-
Once again, initialize the module:
terraform init
-
Then, select the workspace corresponding to the environment you are provisioning the user's access for:
terraform workspace select <prod|prod-sbx|test>
-
Then, run the plan and verify that all of
base
's resources are found and that there are no changes:terraform plan
-
Similarly to step #7, use the
edit-yaml.sh
to open the corresponding environment's.yaml
in your definedEDITOR
:chmod +x scripts/edit-yaml.sh scripts/edit-yaml.sh <prod|prod-sbx|test>
-
Find the block of SSM keys corresponding to SSH, or, if the block of keys do not yet exist, append the below to the end of the file.
....
should be replaced with the user's EUA ID. What each key represents is as follows:-
ssh_access
defines whether the user has the ability to SSH into instances launched in the current environment. If this isfalse
, the user will not have the ability to SSH into any instance, whereas if this istrue
the user will be able to SSH. Note that this is overridden byssh_default_access
(in themgmt
"environment") ifssh_default_access
istrue
. Omission is treated asfalse
-
ssh_sudoer
defines whether the user has the ability to runsudo
and act asroot
on instances launched in the current environment. If this isfalse
, the user will not have the ability to runsudo
and act asroot
, whereas if this istrue
the user will be able to do so. Note that this is overridden byssh_default_sudoer
(in themgmt
"environment") ifssh_default_sudoer
istrue
. Omission is treated asfalse
/bfd/${env}/common/sensitive/user/..../ssh_access: bool /bfd/${env}/common/sensitive/user/..../ssh_sudoer: bool
-
-
Close the file. This will save your changes and re-encrypt the encrypted YAML file for the current environment.
-
Plan the changes to the Terraform state and verify that there are only additions to the state and that these additions correspond to the new SSH SSM parameters defined in step #20:
terraform plan
-
Repeat steps #14 through #21 for each environment that the user should be provisioned in
-
Open a new Pull Request with the changes to all configuration in the associated branch
-
Once approved, the changes to
mgmt
can be applied:-
From the root of the repository,
cd
into themgmt
module:cd ops/terraform/env/mgmt
-
Apply the changes to configuration ensuring that there are no unexpected changes:
terraform apply
-
-
Once approved, the changes to each established environment can also be applied:
-
cd
into thebase
service Terraform module:cd ops/terraform/services/base
-
Switch to the current environment's corresponding workspace:
terraform workspace select <prod|prod-sbx|test>
-
Apply the changes to configuration ensuring that there are no unexpected changes:
terraform apply
-
Repeat the above steps for each established environment that was changed
-
-
Once finished, the new user will be fully provisioned the next time the
Build App AMIs
stage is run in our deployment pipeline. In the meantime, anytime a brand new instance is launched the new user will be able to SSH into it assuming eitherssh_default_access
istrue
or if, for the instance's environment,ssh_access
istrue
It is recommended that you read the following
README
s for more information on the SSM configuration scheme used by BFD before continuing:Additionally:
- You will need to know the user's EUA
-
In your terminal, navigate to the root of your local copy of the
beneficiary-fhir-data
repository usingcd
-
In your terminal, relative to the root of this repository,
cd
to the directory associated with themgmt
Terraform module:cd ops/terraform/env/mgmt
-
Initialize the Terraform state locally:
terraform init
-
Once initialized, view the Terraform plan and verify that Terraform is able to load state for all of the resources managed by the
mgmt
module and that no changes are necessary:terraform plan
-
Navigate into the
base_config
module's directory:cd base_config
-
Ensure you are authenticated with AWS and are able to run AWS CLI commands
-
Open the encrypted yaml
mgmt.yaml
for editing using theedit-yaml.sh
script using the commands below. This will decrypt the encryptedmgmt.yaml
file and open it in your definedEDITOR
. The script will wait until the file is closed by your editor, at which point it will re-encryptmgmt.yaml
with your changes and save itchmod +x scripts/edit-yaml.sh scripts/edit-yaml.sh mgmt
-
You will see many keys grouped together in the format shown below. In the example below,
....
represents each user's EUA ID. Each key represents the following:-
ssh_user
represents the user's SSH username that they will use to connect to a machine using their key -
ssh_public_key
represents the public key component of the user's key-pair -
ssh_default_access
defines whether the user has access, by default, to connect via SSH to any BFD instance in any environment. Essentially, this overrides per-environment access for a given user and should be set totrue
for users that require access in all environments (such as those in our on-call rotation) -
ssh_default_sudoer
defines whether the user hassudoer
permission, by default, for any BFD instance in any environment. Essentially, this overrides per-environmentsudoer
access for a given user and should only be set totrue
for users that need access tosudo
in all environments (such as those in our on-call rotation)
/bfd/mgmt/common/sensitive/user/..../ssh_user: "some.username" /bfd/mgmt/common/sensitive/user/..../ssh_public_key: "ssh-key .... identity" /bfd/mgmt/common/sensitive/user/..../ssh_default_access: bool /bfd/mgmt/common/sensitive/user/..../ssh_default_sudoer: bool
-
-
Knowing the user's EUA, find their corresponding SSM keys and do one of the following to disable their SSH access:
- Simply delete all of the keys associated with the user. This will remove their access globally and should be done if the user is no longer a contributor to BFD. You will still need to check each established environment in order to remove any orphaned SSM keys for environment-specific access
- Set
ssh_default_access
tofalse
. This will disable default access, so you will still need to follow the proceeding steps to modifyssh_access
in all established environments to remove their access completely
-
Close the file. This should immediately update the encrypted
mgmt.yaml
with your new changes -
Return to the
mgmt
module:cd ..
-
Plan the changes to the Terraform state and verify that there are only removals from the state and that these removals correspond to the changes made in step #9:
terraform plan
-
Now that the user's access has been removed in the global
mgmt
module, you will need to check each established environment's configuration to ensure that their access is removed from each -
From the root of the repository, navigate to the
base
Terraform service module:cd ops/terraform/services/base
-
Once again, initialize the module:
terraform init
-
Then, select the workspace corresponding to the environment you are modifying the user's access for:
terraform workspace select <prod|prod-sbx|test>
-
Then, run the plan and verify that all of
base
's resources are found and that there are no changes:terraform plan
-
Similarly to step #7, use the
edit-yaml.sh
to open the corresponding environment's.yaml
in your definedEDITOR
:chmod +x scripts/edit-yaml.sh scripts/edit-yaml.sh <prod|prod-sbx|test>
-
Find the block of SSM keys corresponding to SSH, or, if the block of keys do not yet exist, you can skip to step #23.
....
should be replaced with the user's EUA ID. What each key represents is as follows:-
ssh_access
defines whether the user has the ability to SSH into instances launched in the current environment. If this isfalse
, the user will not have the ability to SSH into any instance, whereas if this istrue
the user will be able to SSH. Note that this is overridden byssh_default_access
(in themgmt
"environment") ifssh_default_access
istrue
. Omission is treated asfalse
-
ssh_sudoer
defines whether the user has the ability to runsudo
and act asroot
on instances launched in the current environment. If this isfalse
, the user will not have the ability to runsudo
and act asroot
, whereas if this istrue
the user will be able to do so. Note that this is overridden byssh_default_sudoer
(in themgmt
"environment") ifssh_default_sudoer
istrue
. Omission is treated asfalse
/bfd/${env}/common/sensitive/user/..../ssh_access: bool /bfd/${env}/common/sensitive/user/..../ssh_sudoer: bool
-
-
Similarly to step #9, there are two options for restricting SSH access in the environment configuration:
- Simply set
ssh_access
tofalse
. Assuming thatssh_default_access
was set tofalse
in step #9, this will disable access to this environment entirely - Remove the keys associated with the user. Assuming that the user's corresponding
ssh_user
andssh_public_key
keys inmgmt
were also removed, the user will no longer have access to SSH into this environment
- Simply set
-
Close the file. This will save your changes and re-encrypt the encrypted YAML file for the current environment.
-
Plan the changes to the Terraform state and verify that there are only removals from the state and that these removals correspond to the changes made in step #20:
terraform plan
-
Repeat steps #14 through #22 for each environment that the user should be removed from
-
Open a new Pull Request with the changes to all configuration in the associated branch
-
Once approved, the changes to
mgmt
can be applied:-
From the root of the repository,
cd
into themgmt
module:cd ops/terraform/env/mgmt
-
Apply the changes to configuration ensuring that there are no unexpected changes:
terraform apply
-
-
Once approved, the changes to each established environment can also be applied:
-
cd
into thebase
service Terraform module:cd ops/terraform/services/base
-
Switch to the current environment's corresponding workspace:
terraform workspace select <prod|prod-sbx|test>
-
Apply the changes to configuration ensuring that there are no unexpected changes:
terraform apply
-
Repeat the above steps for each established environment that was changed
-
-
Once finished, the user's access will be fully updated the next time the
Build App AMIs
stage is ran in our deployment pipeline.
- Home
- For BFD Users
- Making Requests to BFD
- API Changelog
- Migrating to V2 FAQ
- Synthetic and Synthea Data
- BFD SAMHSA Filtering