In my previous post Managing SSH Logins The Way You Are Supposed To I talked about how you should use the SSH config file to manage your SSH login details. The lab example that we used is 1 SSH client and 2 SSH servers which are both 1 hop from the client. 1 hop in a sense that both can be accessed directly from the client. There is nothing standing in between any of them.
Do you ever find yourself trying to remember all the server names or IP addresses along with the usernames you need to log in to them? And what if you're using SSH key-based authentication (like I discussed here) and you're using different keys on different group of servers. It's actually not practical to maintain all of this information externally. In fact, you really are supposed to manage this in SSH itself.
In my last post How To Configure SSH Key-based Authentication on Linux, I gave a walkthrough on how to set up SSH keys with an SSH agent so you get the benefits of passwordless logins while still maintaining the increased security that key-based authentication is supposed to provide. The reason why I reiterate this is because using SSH keys without passphrases pretty much defeats the purpose of using keys at all.
In my last post about The Easiest Way to Build a Network Automation Lab, I have introduced the topic of SSH key-based authentication. Although that post was specific to Networking, this particular post is quite applicable to anything Linux and UNIX-like. I will specifically be performing all procedures on Centos 7 but by no means it will not apply to other Linux distributions. There should be minimal differences, if not, none at all. Let's dive in.
Updated to Python 3.7.0 on Oct 12, 2018
In this setup, I'm using a vagrant machine but you don't necessarily need to do the same thing. Technically these procedures will apply to any computer running Centos 7. For the purpose of development, however, which is what this post is intended for, I highly recommend using vagrant. It makes working with development VMs so much easier.