how to change password in linux vps server

Understanding Linux Password Management

When it comes to securing Linux systems, passwords are often the first line of defense. While passwordless authentication methods are gaining popularity, using a strong password remains a highly recommended practice, especially when you first purchase a Linux VPS server. A robust password policy not only protects your server but also makes it significantly harder for unauthorized users to gain access.

This article is part of Rackset’s Server guides — browse the rest of the category for more in-depth tutorials on this topic.

Linux Password Storage

In Linux, user passwords are stored in an encrypted format within the /etc/shadow file. This file holds critical information about user passwords and is accessible only to the root user or users with sudo privileges. Regular users cannot view the contents of this file, ensuring an added layer of security.

The Role of the passwd Utility

The passwd utility is a command-line tool used to change user account passwords. Normal users can use this utility to change their own passwords, while root or users with sudo access can modify passwords for any user on the system. The basic syntax for changing a password is:

passwd [username]

If you omit the username, the passwd command defaults to changing the password of the current user.

Best Practices for Strong Passwords

Creating a strong password is essential for securing your Linux VPS. A strong password should:

  • Be at least 16 characters long
  • Include at least one uppercase letter
  • Include at least one lowercase letter
  • Include at least one special character

Regularly updating your password is also a good practice to prevent unauthorized access and protect your account from potential threats.

Regular Password Changes

Frequent password changes are a proactive measure to enhance security. By regularly updating your password, you reduce the risk of unauthorized access. This practice is especially important if you suspect that your password may have been compromised.

Summary

Understanding Linux password management is crucial for maintaining the security of your VPS. By utilizing the passwd utility and adhering to best practices for strong passwords, you can significantly enhance the security of your Linux systems.

Accessing Your Linux VPS via SSH

To change passwords on your Linux VPS, you must first access the server. The most common and secure method to connect to a Linux VPS is via SSH (Secure Shell). SSH provides encrypted communication between your local machine and the server, ensuring that your data is protected during transmission.

Prerequisites

  • Your VPS’s IP address or hostname.
  • An SSH client installed on your local machine (e.g., OpenSSH for Linux/Mac or PuTTY for Windows).
  • Login credentials: typically, a username and password or an SSH key.

Using SSH to Connect to Your VPS

Follow these steps to establish an SSH connection to your Linux VPS:

Step 1: Open Your SSH Client

If you’re using a Linux or Mac system, open the terminal. Windows users can use PuTTY or another SSH client.

Step 2: Enter the SSH Command

In the terminal, use the following command to initiate a connection:

ssh username@your_vps_ip_address

Replace username with your actual username and your_vps_ip_address with the IP address of your VPS.

Step 3: Authenticate

Upon executing the SSH command, you will be prompted to enter your password. If you are using SSH keys, ensure your key is loaded into your SSH agent.

If you need this service, Rackset’s team provides professional Linux VPS with full support so you can rely on the quality and get set up quickly.

For example, to load your SSH key, use:

ssh-add /path/to/your/private_key

Step 4: Verify the Connection

Once authenticated, you should see a command prompt for your VPS, indicating a successful connection. You can now proceed with administrative tasks, such as changing passwords.

Troubleshooting SSH Connection Issues

If you encounter issues connecting via SSH, consider the following:

  • Ensure the SSH service is running on the VPS.
  • Check your firewall settings to ensure port 22 (the default SSH port) is open.
  • Verify that your SSH credentials are correct.

By successfully accessing your Linux VPS via SSH, you can manage your server securely and perform essential tasks like changing user passwords.

Changing Your Own Password with passwd

Changing your password on a Linux VPS is a straightforward process that enhances the security of your account. The passwd command is the standard utility for modifying user passwords on Linux systems. This section will guide you through the steps necessary to change your own password using this utility.

Steps to Change Your Password

  1. Open the Terminal: Access your Linux VPS via SSH or directly using a terminal application.
  2. Use the passwd Command: To initiate the password change process, simply type the following command and press Enter:
    passwd
  3. Enter Your Current Password: The system will prompt you to enter your current password for verification. Type it and press Enter.
  4. Enter a New Password: You will then be prompted to enter a new password. Ensure that your new password is strong, meeting the criteria mentioned above: at least 16 characters, including uppercase, lowercase, and special characters.
  5. Confirm Your New Password: Re-enter the new password to confirm it. If both entries match, the system will update your password.

Considerations for a Strong Password

  • Use a combination of letters, numbers, and symbols.
  • Avoid using easily guessable information such as birthdays or common words.
  • Consider using a passphrase composed of random words for easier memorization.
  • Regularly update your password to maintain security.

Troubleshooting Tips

  • Password Mismatch: If you receive a “password mismatch” error, ensure that you enter the new password correctly both times.
  • Password Complexity: If your password does not meet the complexity requirements, choose a stronger password following the guidelines provided.
  • Permission Denied: If you encounter a “permission denied” error, ensure you are logged in as the correct user and have the necessary permissions to change the password.

By following these steps, you can easily change your password on a Linux VPS, ensuring your account remains secure against unauthorized access.

Changing Passwords for Other Users

As a system administrator or a user with sudo privileges, you may need to change the password for other users on your Linux VPS. This section will guide you through the process using the passwd utility. This tool allows you to modify user account passwords effectively and securely.

Prerequisites

To change the password for another user, ensure that you have the following:

  • Root access or sudo privileges on the Linux VPS.
  • The username of the account for which you want to change the password.

Steps to Change User Password

  1. Log in to your Linux VPS: Use SSH to access your server. You can log in as root or a user with sudo privileges.
  2. Open the Terminal: If you are not already in the terminal, open it to execute commands.
  3. Execute the Password Change Command: Use the following command to change the password for a specific user:
sudo passwd username

Replace username with the actual username of the account you wish to modify.

  1. Enter the New Password: You will be prompted to enter a new password. Type a strong password that meets the security requirements.
  2. Confirm the New Password: Re-enter the new password to confirm it. This ensures that you have typed it correctly.

Example

To change the password for a user named john, you would run:

sudo passwd john

Best Practices for Password Management

  • Use a combination of letters, numbers, and special characters to create a strong password.
  • Avoid using easily guessable information such as birthdays or common words.
  • Regularly update passwords to enhance security.

By following these steps and best practices, you can effectively manage user passwords on your Linux VPS, ensuring the security and integrity of your server.

Best Practices for Strong Passwords

Securing your Linux VPS with a strong password is crucial for protecting your system from unauthorized access. While passwordless authentication is an option, many users still rely on passwords for their Linux servers. Here are some best practices to ensure your passwords are robust and secure:

Characteristics of a Strong Password

  • Length: Aim for at least 16 characters. Longer passwords are generally more secure.
  • Complexity: Include a mix of uppercase letters, lowercase letters, numbers, and special characters.
  • Uniqueness: Avoid using common words, phrases, or easily guessable information like birthdays or names.
  • No Repetition: Do not reuse passwords across different accounts.

Password Management Tips

  • Use a Password Manager: Consider using a password manager to generate and store complex passwords securely.
  • Regular Updates: Change your password every 60-90 days to reduce the risk of it being compromised.
  • Two-Factor Authentication (2FA): Enable 2FA for an additional layer of security, where available.

Example of a Strong Password

Here’s an example of a strong password that meets the above criteria:

G7!kL9@bX2#vQ5&z

Additional Security Measures

  • Monitor Access Logs: Regularly check your server’s access logs for any unauthorized login attempts.
  • Limit Login Attempts: Configure your server to limit the number of failed login attempts to prevent brute force attacks.
  • Disable Root Login: Disable direct root login and use sudo for administrative tasks to add an extra layer of security.

By following these best practices, you can significantly enhance the security of your Linux VPS and protect it from potential threats.

For projects that need guaranteed resources and full root control, a VPS is the right step up from shared hosting. With VPS hosting you get dedicated CPU/RAM, NVMe storage, a dedicated IP and high uptime, deployed in minutes.

Troubleshooting Common Password Issues

Changing passwords on a Linux VPS can sometimes lead to unexpected issues. Here are some common problems you might encounter and how to resolve them:

1. Password Change Not Taking Effect

If you have changed your password using the passwd command but it doesn’t seem to work, consider the following:

  • Ensure you are using the correct username. Use the whoami command to verify your current user.
  • Check if the /etc/shadow file is writable. If not, you might need root or sudo permissions to modify it.
  • Verify that the password meets the complexity requirements set by the system’s /etc/pam.d/common-password file.

2. Permission Denied Errors

If you encounter a “Permission denied” error when trying to change another user’s password, ensure you have the necessary privileges:

  • Confirm you have root access or are part of the sudo group. Use sudo passwd username to change another user’s password.
  • Check if your account is locked or restricted from making such changes.

3. Account Locked After Password Attempts

If your account gets locked after multiple failed password attempts, it might be due to the system’s security settings:

  • Check the /etc/security/faillock.conf or /etc/pam.d/common-auth files for lockout policies.
  • Use the faillock --reset --user <username> command to reset the failed attempts counter.

4. Forgotten Root Password

If you forget the root password, you can reset it by booting into single-user mode:

  1. Reboot your server and access the GRUB menu.
  2. Edit the boot parameters by appending init=/bin/bash to the line starting with linux.
  3. Boot the system and use passwd to change the root password.
  4. Remount the filesystem in read-write mode using mount -o remount,rw /.
  5. Reboot the system with exec /sbin/init.

5. Password Expiry Issues

If you’re unable to change a password due to expiry settings, verify the settings in the /etc/login.defs file:

  • Check the PASS_MAX_DAYS and PASS_MIN_DAYS values to understand the policy.
  • Use the chage -l <username> command to view password expiry details.

By following these troubleshooting steps, you can resolve most common password-related issues on your Linux VPS server.

Using sudo for Password Management

In Linux, managing user passwords is a critical task for maintaining the security of your system. Users with sudo privileges have the ability to change not only their own passwords but also those of other users. This capability is particularly useful for administrators managing multiple accounts on a Linux VPS server.

Understanding sudo Privileges

The sudo command allows permitted users to execute a command as the superuser or another user, as specified by the security policy. This is essential for tasks that require elevated privileges, such as changing another user’s password.

Changing Your Own Password

To change your own password using sudo, you can simply use the passwd command. Here’s how:


sudo passwd

You’ll be prompted to enter your current password followed by your new password. Ensure your new password is strong and complies with security guidelines.

Changing Another User’s Password

If you need to change the password for another user, you can do so with sudo by specifying the username. For example, to change the password for a user named exampleuser, you would use the following command:


sudo passwd exampleuser

After executing this command, you’ll be prompted to enter the new password for exampleuser. Remember to inform the user of their new password securely.

Best Practices for Password Management

  • Regularly update passwords to mitigate the risk of unauthorized access.
  • Ensure passwords are complex and meet the recommended length and character requirements.
  • Consider using a password manager to keep track of complex passwords.
  • Limit sudo access to trusted users only to minimize security risks.

Conclusion

Using sudo for password management on a Linux VPS server is an effective way to maintain security and control over user accounts. By following best practices and regularly updating passwords, you can protect your system from unauthorized access and potential security breaches.

For heavy workloads and maximum performance, a dedicated bare-metal server gives you an entire physical machine. Rackset’s dedicated server deliver full hardware, root access and configurable port speeds for the most demanding sites and apps.

Security Tips for Linux VPS Users

Securing your Linux VPS is crucial to protecting your data and maintaining the integrity of your server. Here are some essential security tips to enhance your VPS security:

1. Use Strong Passwords

Always use strong, unique passwords for your accounts. A strong password should have at least 16 characters and include a mix of uppercase letters, lowercase letters, numbers, and special characters. Avoid using easily guessable information like birthdays or common words.

2. Regularly Update Your Passwords

Regularly changing your passwords is a vital security practice. This reduces the risk of unauthorized access if your password is compromised. Use the passwd utility to update passwords:


sudo passwd username

3. Implement Two-Factor Authentication (2FA)

Enhance security by enabling two-factor authentication. This adds an additional layer of security, requiring a second form of verification beyond just the password.

4. Manage User Access

Only provide access to users who need it. Regularly review user accounts and remove any that are no longer necessary. Use groups to manage permissions effectively.

5. Keep Your System Updated

Regularly update your server software and operating system to protect against vulnerabilities. Use the following commands to update your system:


sudo apt update
sudo apt upgrade

6. Configure a Firewall

A firewall can help prevent unauthorized access to your server. Use tools like iptables or ufw to configure your firewall:


sudo ufw enable
sudo ufw allow ssh

7. Monitor Server Logs

Regularly monitor your server logs to detect any suspicious activity. This can help you identify and respond to potential security threats promptly.

8. Disable Root Login

Disable direct root login to prevent unauthorized users from gaining root access. Instead, use sudo for administrative tasks. Modify the SSH configuration file to disable root login:


sudo nano /etc/ssh/sshd_config

Find the line PermitRootLogin and change it to no. Then restart the SSH service:


sudo systemctl restart ssh

By following these security tips, you can significantly enhance the security of your Linux VPS and protect your data from unauthorized access.

Secure Your Server Effortlessly

Unlock the power of seamless security management with Rackset’s Linux VPS. Our robust infrastructure ensures your passwords and data remain protected 24/7, giving you peace of mind in every keystroke.
Empower your server with Rackset today!

Linux VPS

Conclusion

Changing passwords on a Linux VPS server is a crucial task that ensures the security and integrity of your server environment. By following the steps outlined in this guide, you can effectively manage user credentials and protect sensitive data from unauthorized access. Regularly updating passwords and employing strong, unique combinations significantly reduce the risk of security breaches. Remember, maintaining robust password policies is an essential part of server management that helps safeguard your digital assets.

At Rackset, we understand the importance of keeping your server secure and efficient. Whether you’re managing a small personal project or a large enterprise application, our hosting solutions are designed to meet your needs. If you have any questions or need further assistance, our support team is always ready to help. Explore our range of services today and discover how Rackset can empower your online presence.

Frequently Asked Questions

How do I change the root password on my Linux VPS?

To change the root password, log in to your VPS via SSH and use the command `passwd`. Follow the prompts to enter your new password twice for confirmation.

What should I do if I forget my Linux VPS password?

If you forget your password, you can reset it by booting into single-user mode or using a rescue disk provided by your hosting provider. Detailed steps depend on your specific VPS setup.

How often should I change my Linux VPS passwords?

It is recommended to change your VPS passwords every 3 to 6 months to maintain security. Additionally, update passwords immediately if you suspect any security breach.

Are there any best practices for creating a secure password?

Yes, use a mix of uppercase and lowercase letters, numbers, and special characters. Avoid using easily guessable information like birthdays or common words.

Can I automate password changes on my Linux VPS?

Yes, you can automate password changes using scripts and cron jobs. However, ensure these scripts are secure and that you store new passwords safely.

Behzad Nategh
Behzad NateghFounder and CEO

Behzad Nategh is the Founder and CEO of Rackset, with 20+ years in web hosting, cloud infrastructure, and web design. He writes on hosting, domains, security, and growing an online business.

Leave a Reply

Your email address will not be published. Required fields are marked *

Count: 74 - Average: 4.7

Rating Submitted.