How to Change MikroTik Router Password Using Terminal
MikroTik routers are highly versatile and often used in network environments where command-line management is essential. If you’re an administrator, there might come a time when you need to change the router’s password for security or access reasons. In this guide, I’ll walk you through changing the MikroTik router’s password using the terminal, also known as the command-line interface (CLI). This method is quick, efficient, and provides you with complete control over your router’s configurations.
Why Use the Terminal to Change Passwords?
While you can change your MikroTik router’s password via the graphical WinBox interface or the web interface, using the terminal can be faster and more reliable, especially when dealing with remote connections. It’s also useful for automation scripts or when accessing MikroTik devices through SSH.
Prerequisites
- Access to the MikroTik terminal (either locally via WinBox, or remotely via SSH)
- Administrator privileges to change the password
- The current username and password for the router
Steps to Change the Password Using the Terminal
- Log in to the MikroTik Router
To start, you need to access the MikroTik terminal. This can be done using WinBox or by connecting via SSH. If you’re using SSH, open a terminal on your computer and enter:
ssh admin@<router-ip-address>
Replace
<router-ip-address>
with the IP address of your MikroTik router, andadmin
with your current username. Enter the password when prompted. - Navigate to the User Management Section
Once logged in, you need to access the
user
section of the router’s configuration. This is where you can manage existing users and change passwords. Enter the following command:/user
- View the Current User List
Before changing the password, it’s helpful to see a list of existing users to confirm that you’re modifying the correct account. Use the command:
print
This will display a list of all users on the router, along with their group and last login details.
Example output:
Flags: X - disabled, * - default
# NAME GROUP ADDRESS
0 * admin full
1 john read
In this example,
admin
is the default administrator account. - Change the Password
To change the password of a specific user, use the following command structure:
set <user-number> password=<new-password>
Replace
<user-number>
with the number shown in the user list (0
in the example above foradmin
) and<new-password>
with the new password you want to set.For example, to change the password for the
admin
user tonewsecurepassword
:set 0 password=newsecurepassword
Alternatively, you can use the username instead of the number:
set admin password=newsecurepassword
- Verify the Password Change
After changing the password, it’s a good idea to verify that the change has been successful. Log out of the current session by typing:
quit
Now, attempt to log back in with the new password:
ssh admin@<router-ip-address>
Enter the new password when prompted to confirm that it works.
Additional Tips
- Strong Passwords: Always choose strong, complex passwords to secure your router. Consider using a combination of uppercase and lowercase letters, numbers, and special characters.
- Backup Configuration: Before making any changes to your router configuration, including password changes, it’s wise to back up your current configuration. This way, if something goes wrong, you can restore the previous state.
/export file=current-config
This command will create a backup file named
current-config.rsc
that you can download and use for restoration.
Troubleshooting
If you encounter any issues, here are a few things to check:
- Incorrect Username or Password: Double-check that you’re using the correct username and password. If you’ve forgotten your credentials, you might need to reset the router.
- User Permissions: Make sure you have the necessary permissions to change the password. Only users in the
full
group can change passwords.
Conclusion
Changing the MikroTik router password using the terminal is a straightforward process that can be done in just a few commands. Whether you’re securing your network or managing remote devices, knowing how to handle these tasks from the command line is a valuable skill. With the step-by-step instructions provided above, you can easily change the password and enhance your router’s security.
Remember to store your new password securely and periodically update it to maintain robust security practices.
How to Change MikroTik Router Password Using Terminal (F.A.Q)
How do I access the MikroTik terminal?
You can access the MikroTik terminal either through WinBox, by connecting to the router directly, or remotely via SSH using the command:
ssh admin@<router-ip-address>
How do I change the password for a specific user?
Use the command:
/user set <user-number> password=<new-password>
Replace <user-number>
with the user ID (e.g., 0
for admin
) and <new-password>
with the desired password.
How do I verify the password change?
Log out of the current session using quit
, and then log back in using the new password to confirm the change.