In the GitHub repo for my AWS SageMaker project, commits are labelled as being created by the user "EC2 Default User".
How do I customize the name of this user in SageMaker so that it is used every time I start my Notebook Instance?
In the GitHub repo for my AWS SageMaker project, commits are labelled as being created by the user "EC2 Default User".
How do I customize the name of this user in SageMaker so that it is used every time I start my Notebook Instance?
To systematically fix this issue you can use Start notebook configuration in Lifecycle configurations.
Here is the script template:
#!/bin/bash
set -e
cat << EOF >> /home/ec2-user/.gitconfig
[user]
name = John Doe
email = johndoe@example.com
EOF
Please, replace name
and email
with your actual values.
This script will append lines to .gitconfig
file for ec2-user
on SageMaker's machine.
That's the same effect you can manually achieve with following 2 commands:
git config --global user.name "John Doe"
git config --global user.email johndoe@example.com
Because of SageMaker's Notebook Instances start/stop policy:
Only files and data saved within the /home/ec2-user/SageMaker folder persist between notebook instance sessions. Files and data that are saved outside this directory are overwritten when the notebook instance stops and restarts.
you need to add this as Start notebook script, so it will be run every time Notebook Instance is started.
Here is a screenshot how it looks like from AWS Web Console:
Start script config example
Are you pushing from an ec2 instance?
The commit author has nothing to do with which ssh key is used to authenticate the push.
It has to do with the current Git config:
git config user.name
git config user.email
Make sure the values for those local settings are correct (local for the EC2 Git repo), and the next new commits will be with the right author.
I copied and give credit to this post: How to change user identity when git pushing via ssh?
You can also use the built-in Git integration of the SageMaker notebooks to define the user name (and provide the password for it).
Here is a link to a guide: https://aws.amazon.com/blogs/machine-learning/amazon-sagemaker-notebooks-now-support-git-integration-for-increased-persistence-collaboration-and-reproducibility/