Mengelola banyak router dengan password berbeda-beda sulit diaudit. Otomasi bisa membantu mengganti password secara berkala, tetapi penyimpanan kredensialnya harus aman.
Artikel ini menampilkan contoh script Perl dan hal yang perlu dipertimbangkan sebelum dipakai di produksi.
Yang perlu diingat
- Jangan menyimpan password plaintext di repositori atau file yang bisa dibaca publik.
- Uji script pada satu perangkat sebelum menjalankannya massal.
- Catat perubahan dan siapkan jalur pemulihan bila koneksi terputus di tengah proses.
Lupa password admin mikrotik…?
Wah bisa bahaya juga ya … padahal back up setingan sudah lupa naruh, apalagi dead line harus selesai, weh weh… telusur dan telusur akhirnya dapat tutorial mantap nech, tapi sayang pake nya perl… gak masalah untuk coba kenalan lagi ama perl.
yuk mari…
berikut script asli yang saya dapat dari http://blog.butchevans.com
First, the code:
#!/usr/bin/perl
# Update multiple mikrotiks
# change password script
# Copyright (C) 2004 Butch Evans
# butche@butchevans.com
#########################
# Configuration section #
#########################
# The username and password file with connection information
# to connect to your router. This user MUST have read and write permissions
# Each line in this file is in the format:
# routerip::user::userpassword
my $passwdfile = “passwdlist.cfg”;
# If you want to see some output, set this to “1?
my $debug = 1;
# Set the NEW password here
my $newpass = “newpass”;
#############################
# End configuration section #
#############################
# You do not need to change anything below here
# unless you know what you are doing
use strict;
use Net::Telnet ();
# Grab the hosts file (with passwords)
if (! ( -f $passwdfile ) ){
print “ERROR: Password file $passwdfile does not exist!\n\n”;
die;
}
# Slurp the script file into memory
open (PASSWDLIST,$passwdfile);
my @hostlist = <PASSWDLIST>;
close(PASSWDLIST);
my $hostline;
my $host;
my $username;
my $passwd;
#Now, we just cycle through the list of hosts
foreach $hostline (@hostlist){
chomp $hostline;
($host,$username,$passwd) = split(“::”,$hostline);
# Login to the server
if ($debug){
print “Connecting to “. $host .”…”;
}
my $t = new Net::Telnet (Host => $host);
$t->errmode( sub { print “ERROR:” . join(‘|’, @_) . “\n”; } );
$t->login($username, $passwd);
my $errormsg = $t->errmsg;
if ( $errormsg ne “”) {
next; }
# DO THE WORK
my @changepass = $t->cmd(“/user set “. $username .” password=”. $newpass);
if ($debug) {
print “Password change successful\n”;
}
$t->close;
}
exit;
untuk menggunakan :
Saya mengunakan shell linux Ubuntu 11.04 dengan paket perl terinstall dengan benar.
contoh :
IP_mikrotik::user-admin::password-baru
Contoh
10.11.12.13::admin::passwordbaru
selamat mencoba
jadi sekarang jika lupa password mikrotik jangan khawatir lagi, karena kita bisa merubah password mikrotik dengan tool perl ini
Layanan yang berkaitan
Jika Anda ingin menerapkan panduan ini tanpa mengerjakan sendiri, tim Abyfine bisa membantu.
Artikel ini diadaptasi dari arsip Abyfine dan telah disunting untuk format baru. Versi perangkat lunak, harga, angka, dan tautan yang disebut bisa sudah berubah — cocokkan dengan dokumentasi terbaru sebelum menerapkannya di produksi.
Tim teknis Abyfine Intermedia di Cilacap. Kami membangun dan merawat website, server, serta jaringan untuk sekolah, UMKM, dan instansi sejak 2004.