View Full Version : Help to change password over ssh
Hello, I'm trying to change password on AirOS over ssh. I want to do a script that do it automatically in Nano (2/5), Bullet (2/5) and others AirOs based radios.
I have already tried to change the password of file /etc/passwd, but after reboot the old password return. Then I changed the password in file /tmp/system.cfg and the system saved the password after reboot.
In both cases I can access the radio over ssh and web with new password but I can't change the password over the web because it says that current password is wrong.
Thanks for any help.
P.S. Excuse my english, I'm still learning.
freemam
01-25-2010, 02:43 PM
Hello, I'm trying to change password on AirOS over ssh. I want to do a script that do it automatically in Nano (2/5), Bullet (2/5) and others AirOs based radios.
I have already tried to change the password of file /etc/passwd, but after reboot the old password return. Then I changed the password in file /tmp/system.cfg and the system saved the password after reboot.
In both cases I can access the radio over ssh and web with new password but I can't change the password over the web because it says that current password is wrong.
Thanks for any help.
P.S. Excuse my english, I'm still learning.
A writed in the other post..
If you are able to write a script, I can collaborate whit you ;)
A good solution is simulate WEB access to modify the pwd.
Read this link, can help you (scroll up to "Scripting batch operations" section): http://dren.dk/ubi.html (http://dren.dk/ubi.html)
freemam
01-25-2010, 02:44 PM
In both cases I can access the radio over ssh and web with new password but I can't change the password over the web because it says that current password is wrong.
Can you post an example of new password?
drowssap
................
****
freemam
01-26-2010, 02:15 AM
drowssap
................
****
Please?
I have asked how to insert new password in the CFG file... or I are wrong?
Can you post an example of new password?
For example the password "secret".
Using the php crypt() function I got "$1$ParsnnJ0$OC7rna5RByzIv0b3aVxw9". If I change the file /etc/passwd with this encrypted password I'm able to connect over ssh or web, but I can't change the password over web and sometimes I will need it.
I used the sshpass to connect and edit the file /etc/passwd.
Now I'm reading the content on http://dren.dk/ubi.html
skyhook
01-26-2010, 02:54 AM
For example the password "secret".
Using the php crypt() function I got "$1$ParsnnJ0$OC7rna5RByzIv0b3aVxw9". If I change the file /etc/passwd with this encrypted password I'm able to connect over ssh or web, but I can't change the password over web and sometimes I will need it.
I used the sshpass to connect and edit the file /etc/passwd.
Now I'm reading the content on http://dren.dk/ubi.html
Chek for two issues:
1) WEB GUI consider ONLY first 8 chars. If you use longer string, the AirOS consider ONLY first 8 chars.. Check for my old post on this issue... i.e: if you use "abcdefgh1234" as password, you can access the GUI entering "abcdefgh", "abcdefgh1", "abcdefgh12", "abcdefgh1234".. try it!
http://www.ubnt.com/forum/showthread.php?t=7064 (http://www.ubnt.com/forum/showthread.php?t=7064&highlight=password+char)
2) I noticed that same password have DIFFERENT corrispondending string... this can be a problem or not (for this manual editing)?
Make sure that all password are the same on all files (system.cfg, passwd, ...)
1) Yes, I know about the bug of password lenght.
2) I think it depends on wich encrypt function you use. I have already tried to find the encrypt function used by AirOs, but without sucesss.
Fortunately, the script airos-passwd.pl (http://dren.dk/ubi.html) that freeman indicated to me worked fine.
freemam
01-26-2010, 03:31 AM
1) Yes, I know about the bug of password lenght.
2) I think it depends on wich encrypt function you use. I have already tried to find the encrypt function used by AirOs, but without sucesss.
Fortunately, the script airos-passwd.pl (http://dren.dk/ubi.html) that freeman indicated to me worked fine.
Good.
Can you hep me to write a script to enable SSH like airos-passwd.pl script?
What you need exactly?
A script that connect on AirOS over web and check the option "Enable SSH Server" on SERVICES.CGI ?
freemam
01-26-2010, 05:03 AM
What you need exactly?
A script that connect on AirOS over web and check the option "Enable SSH Server" on SERVICES.CGI ?
Yes.
I will send a PM ;)
oojoshua
09-26-2010, 05:39 PM
For the NS5M Mimo gear (v5.2) these scripts no longer work.
Here is a script that will change passwords using the web interface: Adopted from the one posted by the gent above.
Please note that perl is NOT one of my best languages, you have been warned!
#!/usr/bin/perl
use FindBin qw($Bin $Script);
use WWW::Mechanize;
die "Syntax: $Script <user> <old-password> <new-password> <ro-user> <ro-password> <address> ...
Changes the password on 1 or more AirOS units.
" unless @ARGV >= 6;
my $user = shift @ARGV;
my $op = shift @ARGV;
my $np = shift @ARGV;
my $rouser = shift @ARGV;
my $ropass = shift @ARGV;
my @addresses = @ARGV;
open L, ">>$Bin/$Script.log" or die "Unable to write to $Bin.log: $!";
sub l {
print STDERR @_;
print L @_;
}
for my $a (@addresses) {
l "Changing password on $a\n";
my $mech = WWW::Mechanize->new();
my $entry;
my $start = "http://$a/login.cgi?uri=/system.cgi";
$mech->get($start);
$mech->field('username',$user);
$mech->field('password',$op);
$response = $mech->submit(); # to get login cookie
if (!$response->is_success) {
l $response->status_line, "\n";
}
$mech->get(qq|http://$a/system.cgi|);
$mech->field('NewPassword',$np);
$mech->field('NewPassword2',$np);
$mech->field('OldPassword',$op);
$mech->field('ro_status', "enabled");
$mech->field('rousername', $rouser);
$mech->field('roPassword', $ropass);
$mech->field('hasRoPassword', "true");
$mech->click_button(name => "change");
$response = $mech->submit();
if (!$response->is_success) {
l $response->status_line, "\n";
}
$response = $mech->get(qq|http://$a/apply.cgi|);
if (!$response->is_success) {
l $response->status_line, "\n";
}
}
close L;
exit 0;