password – TecAdmin https://tecadmin.net How to guide for System Administrator's and Developers Sat, 31 Dec 2022 18:04:20 +0000 en-US hourly 1 https://wordpress.org/?v=6.1.1 How to Generate Random Password in Python https://tecadmin.net/how-to-generate-random-password-in-python/ https://tecadmin.net/how-to-generate-random-password-in-python/#respond Tue, 27 Dec 2022 09:07:35 +0000 https://tecadmin.net/?p=33004 In Python, you can generate a random password using the secrets module, which is part of the Python standard library. The secrets module provides a secure way to generate random strings, numbers, and other values that can be used for various purposes, such as generating passwords, tokens, or unique IDs. Tips for Generating Secure Passwords: [...]

The post How to Generate Random Password in Python appeared first on TecAdmin.

]]>
In Python, you can generate a random password using the secrets module, which is part of the Python standard library. The secrets module provides a secure way to generate random strings, numbers, and other values that can be used for various purposes, such as generating passwords, tokens, or unique IDs.

Tips for Generating Secure Passwords:

Here are a few tips to keep in mind when generating passwords:

  • Use a strong, random password generator to create passwords that are difficult to guess or crack.
  • Use a different password for each account or service that you use.
  • Use long passwords that are at least 12 characters long.
  • Use a combination of letters, numbers, and special characters in your passwords.
  • Avoid using easily guessable words or phrases in your passwords.

In this tutorial we will discuss two methods to generate random passwords in Python.

Using the Python `secrets` Module

The `secrets` module is part of the Python standard library and provides a secure way to generate random strings, numbers, and other values that can be used for various purposes, such as generating passwords, tokens, or unique IDs.

Here’s an example of how to use the secrets module to generate a random password in Python:

import secrets

def generate_password(length):
    # Generate a random string of hexadecimal digits
    password = secrets.token_hex(length // 2)
    # Return the first `length` characters of the password
    return password[:length]

password = generate_password(17)
print(password)

This code will generate a random password of the specified length, consisting of hexadecimal digits (0-9 and a-f). The generate_password() function uses the secrets.token_hex() function to generate a secure, random string of hexadecimal digits, and then it returns the first length characters of the string.

How to Generate Random Password in Python
Generate Random Password in Python #1

Using the Python `random` Module

You can also use the `random` module from the Python standard library to generate a random password. Here’s an example of how to do that:

import random
import string

def generate_password(length):
    # Generate a list of random characters
    characters = [random.choice(string.ascii_letters + string.digits + string.punctuation) for _ in range(length)]
    # Shuffle the list of characters
    random.shuffle(characters)
    # Return the shuffled list of characters as a string
    return ''.join(characters)

password = generate_password(17)
print(password)

This code will generate a random password of the specified length, consisting of uppercase and lowercase ASCII letters, digits, and punctuation marks. The `generate_password()` function uses the `random.choice()` function to randomly select characters from the `string.ascii_letters`, `string.digits`, and `string.punctuation` strings, and then it uses the `random.shuffle()` function to shuffle the list of characters. Finally, it uses the `join()` function to combine the shuffled list of characters into a single string.

How to Generate Random Password in Python
Generate Random Password in Python #2

I hope this tutorial helps you to understand how to generate passwords in Python scripts!

Conclusion

In conclusion, generating random passwords in Python is a useful task that can be easily accomplished using the random module and the string module. The `random` module provides functions for generating random numbers, and the `string` module provides functions for generating random strings. By combining these two modules, you can generate random passwords of any length and complexity.

You can also use the `secrets` module, which is a more secure alternative to the random module, to generate random passwords. Understanding how to generate random passwords in Python can be helpful in various scenarios, such as when you need to create secure passwords for user accounts or when you want to create unique passwords for different purposes.

The post How to Generate Random Password in Python appeared first on TecAdmin.

]]>
https://tecadmin.net/how-to-generate-random-password-in-python/feed/ 0
How to Force User to Change Password at Next Login in Linux https://tecadmin.net/force-user-to-change-password-at-next-login/ https://tecadmin.net/force-user-to-change-password-at-next-login/#respond Sat, 10 Jul 2021 03:49:49 +0000 https://tecadmin.net/?p=26559 All the Linux systems keeps the users information in /etc/passwd and /etc/shadow files. User password and account aging details are stored in the shadow file. The aging information contains the details of the password change and account status. In this tutorial, you will learn about forcing a user to change their password in Linux. Also [...]

The post How to Force User to Change Password at Next Login in Linux appeared first on TecAdmin.

]]>
All the Linux systems keeps the users information in /etc/passwd and /etc/shadow files. User password and account aging details are stored in the shadow file. The aging information contains the details of the password change and account status.

In this tutorial, you will learn about forcing a user to change their password in Linux. Also will discuss the content stored in the shadow file.

Force User to Change Password

We use passwd command to create or change user passwords in Linux systems. It also allows us to expire any user’s password. Once the password is expired, the system will allow users to log in but force them to change their password before getting the shell access.

You can view user account and password details run below command as sudo privileges account:

sudo change -l username 

To expire users password, type:

sudo passwd --expire username 

Replace “username” with the actual user name of your system.

Force  user to change password in linux

These commands updates the entries in /etc/shadow file.

Hopefully, this FAQ is helpful for you.

The post How to Force User to Change Password at Next Login in Linux appeared first on TecAdmin.

]]>
https://tecadmin.net/force-user-to-change-password-at-next-login/feed/ 0
How To Change User Password in Windows Server 2019 https://tecadmin.net/how-to-change-user-password-in-windows-server-2019/ https://tecadmin.net/how-to-change-user-password-in-windows-server-2019/#respond Tue, 01 Jun 2021 09:59:42 +0000 https://tecadmin.net/?p=26394 Changing password at a regular interval is a good practice for all system administrators. In this production environment, change the password at least every 3 months and for other environments do it every 6 to 12 months. In this tutorial, we will explain the steps to change a user’s password in Windows Server 2019. Prerequisites [...]

The post How To Change User Password in Windows Server 2019 appeared first on TecAdmin.

]]>
Changing password at a regular interval is a good practice for all system administrators. In this production environment, change the password at least every 3 months and for other environments do it every 6 to 12 months. In this tutorial, we will explain the steps to change a user’s password in Windows Server 2019.

Prerequisites

Log in as an Administrator account to your Windows Server 2019 system.

Change User Password in Windows Server 2019

Let’s follow the below steps to change a user’s password in Windows Server 2019.

  1. Search for the system Control Panel and launch it.

    Open Control Panel in Windows Server 2019

  2. Under the User accounts click “Change account type” link:
    Open Accounts in Windows Server 2019

  3. You will see a list of all user accounts. Select the user account, you need to change the password.

    Select Account to Change password in Windows Server 2019

  4. Make sure the correct account is selected. Now click on the “Change the password” link.

    Change users password in Windows Server 2019

  5. Enter your current user password, then provide a new password to set for the user. Make sure you have noted this password in a safe place. Now click on the “Change password” button.

    Set a new password for user in Windows Server 2019

Conclusion

Congratulations, You have successfully changed the password of a user in Windows Server 2019.

The post How To Change User Password in Windows Server 2019 appeared first on TecAdmin.

]]>
https://tecadmin.net/how-to-change-user-password-in-windows-server-2019/feed/ 0
How to Reset Jenkins Admin User Password https://tecadmin.net/reset-jenkins-admin-password/ https://tecadmin.net/reset-jenkins-admin-password/#comments Tue, 15 Dec 2020 06:05:47 +0000 https://tecadmin.net/?p=24367 Jenkins is a popular open-source automation server that is widely used for continuous integration and continuous delivery (CI/CD) in software development. As a system administrator, you may need to reset the Jenkins admin password if you have lost or forgotten it. In this tutorial, we will learn how to reset the Jenkins admin password in [...]

The post How to Reset Jenkins Admin User Password appeared first on TecAdmin.

]]>
Jenkins is a popular open-source automation server that is widely used for continuous integration and continuous delivery (CI/CD) in software development. As a system administrator, you may need to reset the Jenkins admin password if you have lost or forgotten it.

In this tutorial, we will learn how to reset the Jenkins admin password in a few simple steps.

Steps to Reset Jenkins Admin Password

Follow the below steps to recover admin account access to the Jenkins portal.

  1. Disable Current Security – First of all, login to your Jenkins server and edit the Jenkins configuration file (/var/lib/jenkins/config.xml) in your favorite text editor:
    sudo vim /var/lib/jenkins/config.xml 
    

    Disable the security by changing the `useSecurity` tag value to “false”.

    jenkins usersecurity to false

    Save your file and close it. The vim users press the `ESC` button then type `:wq!` and hit Enter to save the file.

  2. Apply Changes – Restart Jenkins service to apply the changes.
    sudo systemctl restart jenkins 
    

    After restarting make sure the Jenkins service is running with `sudo systemctl status jenkins` command.

  3. Access Jenkins as Anonymous User – Again access Jenkins in a web browser, It will redirect you to the dashboard without prompting for authentication. You will be logged in as an anonymous user to Jenkins.
  4. Under the Dashboard, go to the `People` option as seen in below image:
    How to Reset Jenkins Admin Password
    Click “People” button
  5. Delete Admin Account – Select the Admin user account to delete. Then click the "Delete" button to detele the selected account:
    How to Reset Jenkins Admin Password
    Delete admin account

    Click "Yes" to confirm the account deletion.

    Jenkins Reset Admin User Password
    Confirm delete account
  6. Enable Security Again – Now once you deleted old admin user. To reset all security options, go to the “Jenkins” -> “Manage Jenkins” option in left-hand side option lists. Now click on the “Configure Global Security” option
    How to Reset Jenkins Admin User Password
    Go to Global Security Option.

    You will see all option as bellow, do all below mentioned changes on this page

    • Enable the “Enable Security” option.
    • In Security Realm option select “Jenkins own database”
    • Make sure to uncheck the “Allow users to sign up” option under the “Jenkins own database” option.
    • Jenkin Reset Admin Password
      Select “Jenkin’s own user database”

      And

      Reset Jenkins Admin Account Password
      Logged in users can do anything
  7. Save Changes – Save all changes made above.
  8. Create Admin Account – You will be redirected to “Create First Admin User”. Input all required details to create a new Admin account.

    Create a New Admin User in Jenkins
    Create a New Admin User in Jenkins
  9. Login as New Admin User – Now, you can access your Jenkins dashboard using the newly created Admin account.

    Login Jenkins Admin Dashboard
    Login Jenkins Admin Dashboard
  10. All Done

Conclusion

In this tutorial, we learned how to reset the Jenkins admin password in a few simple steps. We hope that this tutorial has helped you understand how to reset the Jenkins admin password and that you are now able to access your Jenkins instance. If you have any questions or need further assistance, please don’t hesitate to ask.

The post How to Reset Jenkins Admin User Password appeared first on TecAdmin.

]]>
https://tecadmin.net/reset-jenkins-admin-password/feed/ 2
How to Remove MySQL Validate Password Plugin https://tecadmin.net/remove-mysql-validate-password-plugin/ https://tecadmin.net/remove-mysql-validate-password-plugin/#comments Wed, 01 Aug 2018 11:21:29 +0000 https://tecadmin.net/?p=16897 The latest MySQL servers come with a validate password plugin. This plugin configures a password policy to make server MySQL more secure. While changing the password, I got the error: ERROR 1819 (HY000): Your password does not satisfy the current policy requirements Remove MySQL Validate Password Plugin In this option, you can simply uninstall the [...]

The post How to Remove MySQL Validate Password Plugin appeared first on TecAdmin.

]]>
The latest MySQL servers come with a validate password plugin. This plugin configures a password policy to make server MySQL more secure.

While changing the password, I got the error: ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

Remove MySQL Validate Password Plugin

In this option, you can simply uninstall the validate_password plugin from your MySQL server. Login to the MySQL command prompt as root user and run the following command on command prompt.

mysql> uninstall plugin validate_password;

Query OK, 0 rows affected (0.05 sec)

If you don’t need to uninstall the plugin, then simply change the password policy of MySQL.

The post How to Remove MySQL Validate Password Plugin appeared first on TecAdmin.

]]>
https://tecadmin.net/remove-mysql-validate-password-plugin/feed/ 2
How to Change MySQL Password Policy Level https://tecadmin.net/change-mysql-password-policy-level/ https://tecadmin.net/change-mysql-password-policy-level/#comments Wed, 01 Aug 2018 11:17:31 +0000 https://tecadmin.net/?p=16893 The latest MySQL servers come with a validate password plugin. This plugin configures a password policy to make MySQL server more secure. While changing the password, I got the error: ERROR 1819 (HY000): Your password does not satisfy the current policy requirements Follow below tutorial to change password policy level for MySQL. Alternatively, you can [...]

The post How to Change MySQL Password Policy Level appeared first on TecAdmin.

]]>
The latest MySQL servers come with a validate password plugin. This plugin configures a password policy to make MySQL server more secure.

While changing the password, I got the error: ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

Follow below tutorial to change password policy level for MySQL. Alternatively, you can also use this tutorial to remove the password policy plugin.

Change MySQL Password Policy

To change the default password policy level, we can change the settings at runtime using the command line or in the config file (my.cnf/mysqld.cnf) permanently.

Login to MySQL command prompt and execute the below query to view current settings of validate_password.

mysql> SHOW VARIABLES LIKE 'validate_password%';

Output
+--------------------------------------+--------+ | Variable_name | Value | +--------------------------------------+--------+ | validate_password.check_user_name | ON | | validate_password.dictionary_file | | | validate_password.length | 8 | | validate_password.mixed_case_count | 1 | | validate_password.number_count | 1 | | validate_password.policy | MEDIUM | | validate_password.special_char_count | 1 | +--------------------------------------+--------+ 7 rows in set (0.01 sec)

The default level is MEDIUM, we can change it to LOW by using the below query. The LOW level required only password’s length to min 8 characters.

mysql> SET GLOBAL validate_password.policy=LOW;

Output
Query OK, 0 rows affected (0.02 sec)

To make this setting permanent edit MySQL configuration (my.cnf) file and add below settings.

[mysqld]
validate_password.policy=LOW

Save the file and restart the MySQL service to apply changes.

The post How to Change MySQL Password Policy Level appeared first on TecAdmin.

]]>
https://tecadmin.net/change-mysql-password-policy-level/feed/ 13
Reset Joomla Admin Password via SQL or phpMyAdmin https://tecadmin.net/reset-joomla-admin-password/ https://tecadmin.net/reset-joomla-admin-password/#respond Sat, 02 Dec 2017 04:36:53 +0000 https://tecadmin.net/?p=14452 Question – How to reset Joomla admin password via SQL query? How to reset Joomla admin password using phpMyAdmin? How to Reset Joomla forgotten password with SQL query? How to find Joomla default admin password? If you have forgotten your Joomla admin password or due to any reason, you are not able to login to [...]

The post Reset Joomla Admin Password via SQL or phpMyAdmin appeared first on TecAdmin.

]]>
Question – How to reset Joomla admin password via SQL query? How to reset Joomla admin password using phpMyAdmin? How to Reset Joomla forgotten password with SQL query? How to find Joomla default admin password?

If you have forgotten your Joomla admin password or due to any reason, you are not able to login to Joomla with admin user. You can simply check the active admin user using SQL query and reset the password with simple SQL query. After updating password with any of below method your Joomla administrator user password will be secret.

Reset Joomla Admin Password via SQL

First, find the ID for of the Joomla administrator account using the following command. Change table prefix im4p8_ with your table prefix of Joomla database.

SELECT * FROM im4p8_users;

If you only have the ID of the admin user account. Update the admin password using the below query. Your Joomla admin password will be secret. You can change it latest from Admin dashboard.

UPDATE im4p8_users set password = 'd2064d358136996bd22421584a7cb33e:trd7TvKHx6dMeoMmBVxYmg0vuXEA4199' WHERE ID = 888;

Reset Joomla Admin Password via phpMyAdmin

You can also connect Joomla database with phpMyAdmin and reset the admin password. Open table *_users and edit the record of the admin user. Now under the password column insert the string “d2064d358136996bd22421584a7cb33e:trd7TvKHx6dMeoMmBVxYmg0vuXEA4199” and save the record by clicking Go button. You password will be secret. You can change it latest from Admin dashboard.

Reset Joomla Admin Password

You can install phpMyAdmin using this tutorial.

The post Reset Joomla Admin Password via SQL or phpMyAdmin appeared first on TecAdmin.

]]>
https://tecadmin.net/reset-joomla-admin-password/feed/ 0
Reset WordPress Admin Password via SQL or phpMyAdmin https://tecadmin.net/reset-wordpress-admin-password/ https://tecadmin.net/reset-wordpress-admin-password/#respond Sun, 05 Nov 2017 09:36:43 +0000 https://tecadmin.net/?p=14080 Question – How to reset WordPress admin password via SQL query? How to reset WordPress admin password using phpMyAdmin? How to Reset WordPress forgotten password with SQL query? How to find WordPress default admin password? If you have forgotten your SugarCRM admin password or due to any reason, you are not able to login to [...]

The post Reset WordPress Admin Password via SQL or phpMyAdmin appeared first on TecAdmin.

]]>
Question – How to reset WordPress admin password via SQL query? How to reset WordPress admin password using phpMyAdmin? How to Reset WordPress forgotten password with SQL query? How to find WordPress default admin password?

If you have forgotten your SugarCRM admin password or due to any reason, you are not able to login to SugarCRM with admin user. You can simply check the active admin user using SQL query and reset the password with simple SQL query.

Reset WordPress Admin Password via SQL

The first query will fetch show the details of the administrator account based on username.

SELECT * FROM wp_users WHERE user_login = 'admin';

If you only have the email address of admin user. Search user details using the command.

SELECT * FROM wp_users WHERE user_email = 'admin@example.com';

WordPress uses md5 encrypted passwords. The query will change the password for the specified username. You must change new_password with your password and ID with the got ID from above queries.

UPDATE wp_users SET user_pass = md5('new_password') WHERE ID = 1;

Reset WordPress Admin Password via phpMyAdmin

You can also connect WordPress database with phpMyAdmin and reset the admin password. Open table wp_users and edit the record of the admin user. Now under the user_pass column, select the MD5 in functions and put plain text password in value section and save it.

Reset WordPress Admin Password

The post Reset WordPress Admin Password via SQL or phpMyAdmin appeared first on TecAdmin.

]]>
https://tecadmin.net/reset-wordpress-admin-password/feed/ 0
How To Use MySQL Commands without Password Prompt https://tecadmin.net/mysql-commands-without-password-prompt/ https://tecadmin.net/mysql-commands-without-password-prompt/#comments Sun, 23 Jul 2017 16:02:53 +0000 https://tecadmin.net/?p=13241 Q. How do I use MySQL command without prompting password? How do I use mysqldump command without using the password in the script? How do I use MySQL commands without passing the password in crontab? In this tutorial, you will find a way to use MySQL commands without passing passwords as a command line parameter [...]

The post How To Use MySQL Commands without Password Prompt appeared first on TecAdmin.

]]>
Q. How do I use MySQL command without prompting password? How do I use mysqldump command without using the password in the script? How do I use MySQL commands without passing the password in crontab?

In this tutorial, you will find a way to use MySQL commands without passing passwords as a command line parameter or password prompt. This is helpful for using MySQL commands in a shell script, or configure MySQL/mysqldump cronjobs without passing password.

  • 1. Create a .my.cnf file in users home directory from which command or script to run.
    vi ~/.my.cnf
    

    and add the following content to this file. Change username and password as per your system configuation.

    [mysql]
    user = myuser
    password = secret
    
    [mysqldump]
    user = myuser
    password = secret
    
  • 2. Now secure the newly created configuration file.
    chmod 600 ~/.my.cnf
    
  • 3. All done. Lets test the setup. I have used the following commands to verify the above configurations. First commands will allow you login to mysql server without prompting password and second command will backup all your databases without password.
    mysql -h localhost -u myuser   
    mysqldump -h localhost -u myuser --all-databases > alldb.sql
    
  • You can use commands in any shell script or schedule crontab for backup. You don’t need to specify MySQL user password in script or command.

The post How To Use MySQL Commands without Password Prompt appeared first on TecAdmin.

]]>
https://tecadmin.net/mysql-commands-without-password-prompt/feed/ 5
How to Set Up Key-based SSH Login in Linux https://tecadmin.net/setup-key-based-ssh-login/ https://tecadmin.net/setup-key-based-ssh-login/#comments Fri, 27 Jan 2017 13:14:56 +0000 https://tecadmin.net/?p=241 In the early 90s, IT professionals were using Telnet for data transfer which was an application layer protocol and used to transfer data without encryption. Later a secured alternative of Telnet SSH was created which encrypts the data so that others cannot retrieve it without access. SSH or Secure Socket Shell is a network protocol [...]

The post How to Set Up Key-based SSH Login in Linux appeared first on TecAdmin.

]]>
In the early 90s, IT professionals were using Telnet for data transfer which was an application layer protocol and used to transfer data without encryption. Later a secured alternative of Telnet SSH was created which encrypts the data so that others cannot retrieve it without access.

SSH or Secure Socket Shell is a network protocol used to access a system or server remotely in a secured way. It is an application layer protocol and it enables you to access another machine without physical access remotely via the internet. With SSH you can issue remote commands, transfer files, connect to remote servers, and can communicate between two computers in an encrypted way.

You can log in to your remote SSH server by types:

  • Password Authentication
  • Public Key Authentication (Passwordless)

Here we will discuss configuring key-based authentication for SSH login.

Step 1 – Generate SSH Key Pair

Firstly you would require generating a key pair (RSA or DSA), you can specify option RSA or DSA key using '-t' command-line switch. If we do not pass the -t parameter, it will default create a RSA key.

ssh-keygen -t rsa 

Follow the quick wizard:

  1. Enter and accept the default location. You can also select a different filename and location.
  2. Next, you will be asked for a passphrase. It depends on you that if you want it or not. If you do not want it then press Enter otherwise enter a passphrase for an extra layer of security. Also, not using a passphrase will help you in automating a lot of tasks.
  3. Hit Enter and your keys will be created.

Now, you can see the generated key files with the following command.

ls -l .ssh/ 

Step 2 – Copy Public Key to Remote System

the ~/.ssh/authorized_key is the file responsible for keeping public keys of remote clients. During the key-based authentication, the system checks for the public keys in the same file.

You can simply copy the content of public-key (file with .pub extension) from your system to the authorized_key file on the remote server. Otherwise, let it be done by running the following command.

ssh-copy-id -i ~/.ssh/id_rsa.pub 192.168.10.20 
Output:
21 root@192.168.10.20's password: Now try logging into the machine, with "ssh '192.168.10.20'", and check in: .ssh/authorized_keys to make sure we haven't added extra keys that you weren't expecting.

You will be asked for the remote_user password. Once you enter the correct password, the public key will be stored in the remote server.

Step 3 – Verify SSH without Password

Now as we have all done, simply try to ssh to the remote system. You will log in to the remote system without entering the password.

ssh root@192.168.10.20 

You should log in automatically now, without prompting for the password. If in case, the system is prompted for the password, means the key is not correctly copied on the destination server. To resolve this, check the key is properly appended to the authorized_key file and its permissions.

Conclusion

In this tutorial, you have learned to create SSH key pair and configure key-based login between two systems.

The post How to Set Up Key-based SSH Login in Linux appeared first on TecAdmin.

]]>
https://tecadmin.net/setup-key-based-ssh-login/feed/ 4