Community discussions

MikroTik App
 
User avatar
eben
Member
Member
Topic Author
Posts: 479
Joined: Mon Feb 16, 2009 8:37 pm
Location: Somerset West, South Africa
Contact:

Changing a user's password via terminal

Sun Jul 21, 2013 2:46 am

How do I change a user's password via the terminal.

Let's say user admin is user 0 on the list. What's the /user ... command to change the password?

Thanks
 
User avatar
omega-00
Forum Guru
Forum Guru
Posts: 1167
Joined: Sat Jun 06, 2009 4:54 am
Location: Australia
Contact:

Re: Changing a user's password via terminal

Mon Jul 22, 2013 2:46 am

ros code

/user set [find name=username] password=password
Is this what you're looking for?
 
User avatar
eben
Member
Member
Topic Author
Posts: 479
Joined: Mon Feb 16, 2009 8:37 pm
Location: Somerset West, South Africa
Contact:

Re: Changing a user's password via terminal

Mon Jul 22, 2013 6:28 am

ros code

/user set [find name=username] password=password
Is this what you're looking for?
That is perfect. Thank you.
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8709
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Changing a user's password via terminal

Tue Jul 23, 2013 2:53 am

well,
/user set admin password=bla-bla
works fine for me :)
 
User avatar
omega-00
Forum Guru
Forum Guru
Posts: 1167
Joined: Sat Jun 06, 2009 4:54 am
Location: Australia
Contact:

Re: Changing a user's password via terminal

Tue Jul 23, 2013 5:29 am

That is correct, we both missed covering edge cases though.. IE:

ros code

/user set [find name="michael.o'hara"] password=test123
Which works, but will not work if you try it with either of our original examples:

ros code

/user set michael.o'hara password=test123
or

ros code

/user set [find name=michael.o'hara] password=password
Here's to best practise and people with weird names hahahah :-P

Edit: As pointed out usernames with 's are not allowed as router users, they are however able to be created as ppp secrets (and I'm assuming as usermanager accounts?)
Last edited by omega-00 on Wed Jul 24, 2013 5:42 am, edited 1 time in total.
 
User avatar
normis
MikroTik Support
MikroTik Support
Posts: 26289
Joined: Fri May 28, 2004 11:04 am
Location: Riga, Latvia

Re: Changing a user's password via terminal

Tue Jul 23, 2013 10:07 am

if a person uses michael.o'hara as his login name, he can only blame himself :)
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8709
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Changing a user's password via terminal

Tue Jul 23, 2013 1:34 pm

well, I can't create a user with apostrophe or space in the name (router says 'Invalid user name') - so edge cases are cut by smart routerOS :D
 
User avatar
normis
MikroTik Support
MikroTik Support
Posts: 26289
Joined: Fri May 28, 2004 11:04 am
Location: Riga, Latvia

Re: Changing a user's password via terminal

Tue Jul 23, 2013 1:36 pm

well, I can't create a user with apostrophe or space in the name (router says 'Invalid user name') - so edge cases are cut by smart routerOS :D
http://xkcd.com/327/
 
User avatar
omega-00
Forum Guru
Forum Guru
Posts: 1167
Joined: Sat Jun 06, 2009 4:54 am
Location: Australia
Contact:

Re: Changing a user's password via terminal

Wed Jul 24, 2013 5:40 am

well, I can't create a user with apostrophe or space in the name (router says 'Invalid user name') - so edge cases are cut by smart routerOS :D
I know I'm being pedantic, but you can create those in other areas (like ppp secrets etc) so if someone is trying to use the same code for other similar functions they might run into that.

Poor Michael O'Hara.. or in our case I managed to find an existing customer with the last name Fox-d'Alpuget.. one day I'll name my Son Timo+hy so he has a terrible time getting email addresses for work or uni :-D
 
User avatar
normis
MikroTik Support
MikroTik Support
Posts: 26289
Joined: Fri May 28, 2004 11:04 am
Location: Riga, Latvia

Re: Changing a user's password via terminal

Wed Jul 24, 2013 9:55 am

Off topic, but your son would simply get the address timo@something.com because using +hy is a valid tagging system for filtering mail. Ie. sending something to timo+hy@something.com would go to timo@something.com
 
User avatar
vazhagelashvili
just joined
Posts: 2
Joined: Wed Dec 23, 2015 10:00 pm
Contact:

Re: Changing a user's password via terminal

Thu Dec 24, 2015 10:53 am

well,
/user set admin password=bla-bla
works fine for me :)
Hi,I wonder how to list users .Thanks in advance!
 
Almohalla
just joined
Posts: 10
Joined: Fri Jan 15, 2016 7:31 pm

Re: Changing a user's password via terminal

Thu Feb 09, 2017 7:32 pm

well,
/user set admin password=bla-bla
works fine for me :)
Hi,I wonder how to list users .Thanks in advance!
to list users
/user print
 
LaZyLion
newbie
Posts: 32
Joined: Fri May 09, 2014 10:27 am

Re: Changing a user's password via terminal

Wed Feb 01, 2023 2:36 am

Is there a way to mask a password in a script?

Instead of
 /user set admin password=bla-bla

you'd use
 /user set admin password-md5=f56e8aca4cdfaefba307865a179e28a7


Field techs can have user-level passwords, but I'd like to at least pretend I'm protecting my admin passwords from curious Georges.

Who is online

Users browsing this forum: GoogleOther [Bot], johnson73 and 71 guests