I did not find any reference to user related commands for the jenkins-cli tool.
I need this to automate deployment.
Any comeback?
To use jenkins internal database simply use the following command.
echo 'jenkins.model.Jenkins.instance.securityRealm.createAccount("user1", "password123")' | \
java -jar jenkins-cli.jar -s http://localhost:8080/ groovy =
This will create user=user1 with password=password123
If you have any existing user and have restricted anonymous access to your jenkins, you can specify the username and password with
--username "user_name" and --password "password"
Maybe you don't want to use Jenkins' internal user database at all. There are a host of "Authentication and User Management" plugins.
If you like MySQL, there is a MySQL authenticator (it reads a table of users and passwords), and your "adduser" command could do an insert on that table.
If you like flat files, there is a "Script Security Realm", where you can authenticate with an arbitrary script. Write a file with user and password combos in your favorite format, write an "adduser" script that writes to it, and write an auth script that reads the file and determines whether to authenticate the user.
You can also hook up to an LDAP server, Active Directory, Atlassian Crowd, Unix user accounts (pw_auth), or whatever authentication your application server uses (if it's running off of a Tomcat server, for instance, you can tell Jenkins to let Tomcat authenticate users, and set up Tomcat to do it however you want.
If you specify in more detail what you are trying to do people here may help you better. That said, here are some pointers:
All CLI commands are available via http://[jenkins-server]/cli. What's not found there is not available via CLI. You can specify user name / password via --username and --password (or --password-file) options in CLI commands.
Another option for Jenkins automation is to use Python JenkinsAPI.
You can also use tools like wget and curl to perform certain actions (such as starting a build). There you may use user-specific tokens instead of username/password.
Here's another link that can be helpful.
Related
How can I script out a update to a servicemix system bundle using karaf's client.bat? When I try to run ./client.bat "update 111" -p <password> through powershell I get a java.lang.NullPointerException. I believe it is because updating this bundle requires the user to type yes on the server when it asks "You are about to access system bundle 111. Do you wish to continue (yes/no):" Any way I can get around this?
Specify user and password first then specify command you want to run.
Example:
# Default user and password
./client.bat -u karaf -p karaf -- "update 111"
Don't recall Apache Karaf asking for confirmation when it comes to bundle:update. If service mix has such thing you might want to check bundle:update --help to see if there's option to skip it.
I installed Keycloak 17.0.0 but not able to create admin user. I followed this document.
When I access Keycloak page, it is showing "you need local access to create the initial admin user". Screenshot is here - Keycloak. Also I didn't find the add-user-keycloak script in Keycloak 17.0.0. I am quite new to this. Can anyone help on how to create the initial admin user?
Thanks in advance.
I to have been trying to play around with Keycloak 17, and have found it far from easy to get it to work as I expected.
I am trying to get it work on remote server,where its impossible to login on localhost. To create the admin user I followed the information in the Keycloak document at KeyCloak documents, see the section called Creating the first administrator
You set the following envronmental variables
export KEYCLOAK_ADMIN='username'
export KEYCLOAK_ADMIN_PASSWORD='password'
bin/kc.[sh|bat] start
Were username and password are strings for username and password.
Another problem I had was getting Keycloak to work on my server haggis on port 8085. My solution was to invoke it as follows.
./kc.sh start-dev --http-port=8085 --http-host=haggis --db-url-host=haggis --db-username=kc --hostname=haggis:8085 --hostname-admin=haggis:8085 --hostname-strict-backchannel=true --db-url-database=postgresql --db-username='kcuser'
This command line instructs Keycloak to start up on the server haggis, at port 8085, using a postgres database with a database user called kcuser in development mode.
My largest problem was working out that you had to include the port number in the hostname style arguments.
Once everything is working you can invoke it as
http://haggis:8085/admin/master/console/#/realms/master
Ok, someone far cleverer than I figured this out:
export KEYCLOAK_ADMIN=admin
export KEYCLOAK_ADMIN_PASSWORD=admin
sudo -E bin/kc.sh start-dev
https://github.com/keycloak/keycloak/discussions/10262
But don't use admin/admin of course...
I have backed up the data from my deployed database successfully using the following commands:
mongodump admin -u user -p password
Is there a shell script to do this automatically with the password hidden(to protect the password even someone get the script)?
You can use crontab to create scheduled task on the server that will run this command for you. in that way only those who have access to the server can get your password.
Here is a link how to do it https://sheharyar.me/blog/regular-mongo-backups-using-cron/
You should implement the solution by Ariel with a read-only user. This limits the damage when someone still manages to obtain the script. It would also be good practice to store the password encrypted and let the scrip that runs the backup decrypt it.
i am trying to install jboss-fuse-6.1.0.redhat-379
and i am able to create esb:create-admin-user via console but not i am trying to automate installation via shell script .
i am able to start fuse server but not able to create user
esb:create-admin-user.
below is sample script for creating user.
!/bin/ksh
cd $HOME/jboss-fuse-6.1.0.redhat-379/bin
./fuse esb:create-admin-user --new-user admin1 --new-user-password admin12
but it is not creating user.
please let me know how i can do this .
This could be the issue with file write access present in etc .
Here is the another solution for that
Go to jboss-fuse-6.1.0.redhat-379/etc folder
Open users.properties file and add username=password,admin
Last word admin is the "Admin" role.
You are probably looking for the bin/client script to execute commands against a running fuse instance. But for that you will need a username/password ;)
If you want to automate it is indeed probably easier just to use #mahesh-biradar approach:
echo "admin1=admin12,admin" >> etc/users.properties
I am trying to install postgresql on a server using a bat file. I am using initdb.exe with --pwfile option so that it picks up the password form a text file and continues...
for some reason, even with --pwfile option, it is still prompting me for a password.. Not sure what the problem is.. This is the script I am using:
set DBPATH = something
set DBADMIN = something
set DBDATA = something
RunAs /noprofile /user:%computername%\postgres ""%DBPATH%\initdb.exe" --locale=C --encoding=UTF-8 -U %DBADMIN% --pwfile="D:\Pass.txt" -D "%DBDATA%""
Thanks
If you want to install a software which requires for the installation administrator privileges and the current user account does not have the required privileges, it is possible to use command RunAs to run the installation executable and all processes started by this application with a different user account than the current user account which has the required privileges.
But the user has to enter nevertheless a password - the password for the other user account with the extended privileges to install applications. If it would be possible to run something requiring extended privileges for installing software without requesting entering the password by the user, every bad guy out in the world could very easily install trojaners and other malware (as it is possible on Windows 2000 / XP or since Windows Vista with user account control disabled).
There are systems to deploy and install software on all clients of a company like Group Policy or System Center Configuration Manager.