How can I change the Session Manager shell to bash on EC2 Linux instances?
Last updated: 2021-03-24
I want to change the Session Manager default shell on my Amazon Elastic Compute Cloud (Amazon EC2) Linux instance. How can I do that?
- Shell preferences
- Environment variables
- Working directories
- Running multiple commands when a session starts
You can enable configurable shell profiles using the Systems Manager console or the AWS Command Line Interface (AWS CLI).
To enable shell profiles, you must use SSM Agent version 22.214.171.124 or later. Check the SSM Agent version number on your instance. If necessary, update SSM Agent. For more information, see Automating updates to SSM Agent.
To see the available shells on the instance, run the following command:
$ sudo cat /etc/shells
Note: You can use any of the shells returned using this command.
Enable configurable shell profiles (console)
To enable configurable shell profiles and change the shell to bash using the Systems Manager console, follow these steps:
1. Open the Systems manager console, and then choose Session Manager from the navigation pane.
2. Choose the Preferences tab, and then choose Edit.
3. For "linux" under "shellProfile", enter the following:
4. Choose Save.
Enable configurable shell profiles (AWS CLI)
Note: If you receive errors when running AWS CLI commands, make sure that you're using the most recent version of the AWS CLI.
For instructions to enable configurable shell profiles and change the shell to bash using the AWS CLI, see Create Session Manager preferences (command line).
Other shell profile configuration options
You can also use the shell profile to load specific environment variables, or to run a script at the start of the session. For example, to add the PYTHONPATH environment variable, add the following command to your shell profile:
When you are logged in, you can run the following command to verify that the environment variable is correctly set:
$ sudo env