Skip to content

Instantly share code, notes, and snippets.

@galvarado
Created January 17, 2019 23:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save galvarado/d6ee84fe738f641ad486491a7ef6099d to your computer and use it in GitHub Desktop.
Save galvarado/d6ee84fe738f641ad486491a7ef6099d to your computer and use it in GitHub Desktop.
username="myusername"
hash="$(echo -n 'thenewpass{s4lt}' | sha256sum | awk '{print $1;}')"
echo "Changing password for $username"
echo "Password encrypted with SHA-256"
sed -i -E "s/(<passwordHash>.+)/<passwordHash>s4lt:$hash<\/passwordHash>/" /var/lib/jenkins/users/$username/config.xml
echo "Replaced succesfully, restarting jenkins service..."
service jenkins restart
echo "Jenkins restarted"
service jenkins status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment