...
Of course there is nothing stopping you from assigning a public IP address to every instance in your cluster, however you may prefer to keep external exposure to a minimum, especially if the bulk of the work the cluster will be doing is on the private network.
SSH Access
All 5 instances should have your SSH key loaded onto them, however only one (test-instance-1) you will be able to SSH to directly from your desktop:
...
In theory, you should be able to SSH from test-instance-1 to any of the other instances. However, as the instances are by default passwordless, you will need to use your SSH key to connect to them. There are a couple of different ways this can be done.
Copy SSH Key
The most direct approach is to manually copy your SSH key (both the private and public components) from your desktop to test-instance-1. That way you can use your credentials directly when SSHing to any other instance in the cluster:
...
The main drawback with this approach is that you may not want to have your SSH key stored on more machines than necessary, from a security perspective.
SSH Agent Forwarding
If you have a Linux or Mac based desktop, you can instead forward your SSH credentials from your desktop through your SSH connection to test-instance-1. This is done using ssh-agent. The exact process may vary depending on your specific operating system; the steps outlined below are for setting this up under Ubuntu 16.04.
...
Code Block |
---|
phi216@shinobu-kf:~$ ssh ubuntu@146.118.113.9 ---8<--- ubuntu@test-instance-1:~$ ssh 192.168.1.56 |
Hosts File
It is probably also worth adding all of the instances in your private cluster to /etc/hosts on test-instance-1. That way, connecting to them will be simpler. Just add the entries to the end of your hosts file:
...
Code Block |
---|
ubuntu@test-instance-1:~$ for i in {2..5}; do ssh test-instance-$i 'ip a | grep 192.168'; done inet 192.168.1.56/24 brd 192.168.1.255 scope global ens3 inet 192.168.1.58/24 brd 192.168.1.255 scope global ens3 inet 192.168.1.53/24 brd 192.168.1.255 scope global ens3 inet 192.168.1.62/24 brd 192.168.1.255 scope global ens3 |
Using pdsh
When running commands across all instances in the cluster, there are a number of tools that allow you to run parallel commands. One of the simplest ones is pdsh, which you only need to install on test-instance-1:
...