Ubnt Generate Rsa-key Command Get Public Key
Ubnt Generate Rsa-key Command Get Public Key 4,0/5 2601 reviews

Sep 08, 2016  This video is aimed at using SSH RSA private/public keys as an alternative to password authentication on a Ubiquiti EdgeMax device. The program used in this video is puttygen.

How do I generate ssh RSA keys under Linux operating systems?
You need to use the ssh-keygen command as follows to generate RSA keys (open terminal and type the following command):
ssh-keygen -t rsa
OR
ssh-keygen
Sample outputs:

Advertisements

The -t type option specifies the type of key to create. The possible values “rsa” or “dsa” for protocol version 2. The $HOME/.ssh stores the following two files:

  • $HOME/.ssh/id_rsa – Your private RSA key
  • $HOME/.ssh/id_rsa.pub – Your public RSA key

Please do not share keys file with anyone else. You can upload keys to remote server as follows:
ssh-copy-id [email protected]
Finally, you can login to remote server as follows:
ssh [email protected]
scp file.txt [email protected]:~/data2/

See also:

  • Howto Linux / UNIX setup SSH with DSA public key authentication (password less login)
  • sshpass: Login To SSH Server / Provide SSH Password Using A Shell Script
  • keychain: Set Up Secure Passwordless SSH Access For Backup Scripts

ADVERTISEMENTS

This blog post is part of a series on EdgeRouter Lite. Grid 2 cd key generator download 2017. You may want to check them all out!

DateTitleDescription
03/13/16My Home Router – EdgeRouter LiteQuick introduction to EdgeRouter Lite
04/09/16Ubiquiti’s EdgeOS CLI IntroductionEdgeOS CLI Primer
05/01/16How to configure EdgeRouter Lite via CLI – Part 1EdgeOS configuration guide for CLI junkies
05/01/16How to configure EdgeRouter Lite via CLI – Part 2EdgeOS configuration guide for CLI junkies
12/04/16Hardening EdgeRouter Lite – Part 2EdgeOS with two-factor authentication
12/05/16Hardening EdgeRouter Lite – Part 3Management ACL
12/06/16Hardening EdgeRouter Lite – Part 4Remote Access VPN with two-factor authentication

Introduction

Ubnt Generate Rsa-key Command Get Public Key

It has been a while since I talked about my EdgeRouter Lite. Since then, my configuration has changed. I will be discussing some of the configuration changes in this series of blog posts.

As the title implies, I will cover the process of hardening EdgeRouter Lite to address the security concerns one might have with my two-part blog post. This, by no means, is complete or the most secure configuration so feel free to drop me a line with your suggestions.

Note: This post is based on firmware version 1.9.

Web UI

The HTTPS service listens, by default, to all addresses assigned to router’s interfaces. We can improve security by restricting web management traffic to a single address.

Alternatively, I could disable the service if I have no use for it.

One of the things I noticed in EdgeOS is that it listens to port 80 and 443. However, users that try to hit the router via HTTP will be redirected to HTTPS. The show service gui command won’t list it but when you issue show configuration commands match “service gui” then it will show up. This behavior is OK in my opinion since it switches to secure HTTP. Though, there might be some people who will find this unacceptable. If you are one of them, the delete service gui http-port 80 command will disable this. Alternatively, one can just use the firewall to block it. I will cover the firewall configuration in future blog posts.

SSH Service

In my how to configure EdgeRouter Lite part one guide, my SSH service section has two config lines. While it touches a bit about security, I didn’t really touch on securing the service further. By default, the router’s SSH server will listen to any addresses assigned to an interface, just like the Web UI. In this section, we will instruct EdgeOS to only listen to a specific IP address.

Public-Key Authentication

One of the mitigation techniques for SSH brute force attack is by using SSH key authentication method. In order to do this, we will need to generate SSH keys on the client(s), load the public key on EdgeRouter, and disable password authentication.

Generating SSH keys

In this post, the host that I used to generate keys runs on Ubuntu Server 16.04.1. Generating keys on macOS and other Linux distro might be the same command. If you’re a Windows user, please research on how to generate keys using PuTTY Generator.

Copying SSH key

There are two methods, that I know of, on how to copy the public key that we generated to the EdgeRouter. I will only cover two of them.

Method 1

Ubnt Generate Rsa-key Command Get Public Key In Unix

Ubnt Generate Rsa-key Command Get Public Key

This method is the easiest out of the two. This method will only work if password authentication is still enabled. If not, then you will have to use the second method.

The public key is now copied and we are now ready to load the key. Skip the method 2 section and go to the next.

Method 2

This method is a bit more involved than the first one. The second part of this method is applicable to Windows users. It’s just a matter of copying the public key to clipboard and saving it to a file in EdgeRouter. This will be the method you’ll use going forward when you disable password authentication and need to add more public keys. Alternatively, you can enable password authentication temporarily and use the first method to add more public keys. Don’t forget to disable password authentication.

The first step is to view the public key from the host.

The next step is to copy everything. Note: It may show up as multiple lines on your screen. Make sure to paste it as a single line to a file in EdgeRouter.

If you are not familiar with VI/VIM editor, then use this.

Loading SSH key

The next step is to load the public key to the configuration. The command covered here instructs the router to load the public key from the Linux environment to EdgeOS. This ensures that the keys will survive a reboot and/or firmware upgrade since configurations will be saved in /config directory.

We’ll delete the authorized_keys file since it is no longer needed.

Disable Password Authentication

Ubnt Generate Rsa-key Command Get Public Key From Private Key

The last step in enabling public key authentication is to disable password authentication. Right now, users are still able to log into the EdgeRouter using password. To disable this behavior, we’ll need to configure SSH daemon to only allow public key authentication.

For this to take effect, we’ll need to commit the changes and save the config to the config.boot file. The command below will cause SSH daemon (sshd) to restart.

Verification

Now, we’re ready to test our EdgeRouter configuration.

Host with public key

Here’s my Ubuntu host with public key connecting to EdgeRouter Lite.

Depending on your host’s OS, the behavior may be different. My host likes to ask for the private key passphrase every time I try to connect to EdgeRouter Lite. This requirement of passphrase could serve as an additional layer of security. Though, this depends if the user is using a unique and secure passphrase. To modify this behavior, I had to add the identity to the key manager so I don’t have to keep typing every single time. I will leave it to your discretion if you want to do the same thing.

Installing key manager

Install keychain package as the key manager.

Edit the .bashrc file and add the following.

If you are not familiar with VI/VIM, follow the commands below.

For the change to take effect, enter the command below.

Now, my host is no longer asking for passphrase every time I try to connect to my EdgeRouter. Though, this will not survive a reboot. It will prompt me again to enter the passphrase when the host reboots. This is better than entering the passphrase every time, though!

Host with no public key

Clients that do not have public keys saved in the EdgeRouter will no longer be able to connect.

Final Words

This post addresses some of the security concerns with my two-part blog post on how to configure EdgeRouter Lite. While there were few security bits here and there in the series, this post increases security by hardening the management plane. There will be more things we can do to enhance management security but will be covered in the future. The next post will give users an alternative to SSH public-key authentication.

Are you ready to improve your network security?

Let us answer more questions by contacting us. We’re here to listen and provide solutions that are right for you.

References

Ubnt Generate Rsa-key Command Get Public Key From Certificate

Ubuntu Community QuickTips
Ubiquiti Community – SSH authorized_keys

Ubnt Generate Rsa-key Command Get Public Key Linux

Disclosure

NetworkJutsu.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com.