sexta-feira, 18 de novembro de 2016

MikroTik - Tutorial RouterOS SSH Public Key Auth using RSA keys



A Step-by-Step guide to configure SSH Public Key Authentication on a MikroTik router using an RSA keys

In RouterOS 6.31, MikroTik introduced support for RSA keys for authentication so I decided to give it a test. SSH Public Key Authentication on RouterOS using DSA keys has been supported for a long while. This MikroTik tutorial will guide you through the process of configuring authentication with RSA keys. This tutorial is really three articles in one, pick the one that fits your environment. SSH from a Linux host, Putty on Windows, or SecureCRT on Windows.

Ubuntu Generate an RSA key pair on ubuntu linux

Ubuntu Step 1: Run ssh-keygen

Ubuntu Step 2: Copy the public key to the MikroTik router

Next, skip down to Install the public key

Generate an RSA key pair using SecureCRT (Windows)

Important If you have already created a private/public key in the past using SecureCRT make sure you backup your keys or just use the existing key pair. You have been warned.
SecureCRT | Global Options | SSH2
Before you start, choose “Options | Global Options | SSH2” from the menu to see if you have already generated and configured a SSH key pair.
SecureCRT | Tools | Create Public Key...
Choose “Tools | Create Public Key…”
SecureCRT Create Key Dialog
Click “Next”
SecureCRT Choose between DSA and RSA key generation
Choose between DSA and RSA key generation, RSA for this tutorial.
SecureCRT For passwordless auth do not specify a passphrase
Leave Passphrase blank for true passwordless authentication
SecureCRT Use a key length of 2048
Use a key length of 2048
SecureCRT Key Generation Step
Click “Next” after the RSA key is generated
SecureCRT Choose where to save your key pair
Choose where to save your key pair, I created a folder in My Documents named “sshkeys”.
Next, skip down to Install the public key

PuTTY Generate SSH Key pair using PuTTY’s puttygen.exe (Windows)

Run puttygen.exe
Click “Start | Run” and launch “C:\Program Files (x86)\PuTTY\puttygen.exe”
Puttygen.exe Generate
Ensure that key type is “SSH-2 (RSA)” and key length is “2048”. Click “Generate”.
puttygen.exe save the generated public and private keys
Click “Save private key” and “Save public key” to save each. I saved them to My Documents\sshkeys and named the public key “puttykey.pub”.

Winbox Install the Public RSA key and associate it with a user

Winbox Step 1: Use winbox to verify that the file was copied to the router

Winbox Files List

Winbox Step 2a: Import the public key using Winbox

Import SSH public key using Winbox

Winbox Step 2b: Import the public key from the command line

To verify…

Test your configuration by connecting with SSH

Look, no password prompt!

How to export router’s configuration using SSH

Again, no password prompt!

How to create a binary backup and transfer using scp


fonte: http://jcutrer.com/howto/networking/mikrotik/routeros-ssh-publickeyauth-rsa-keys

0 comentários: