Advanced SSH Settings
When setting up SSH access to Kubernetes nodes, you can configure additional options for easier connection, such as SSH keys or connection shortcuts.
Setting Up SSH Keys
To make the SSH connection easier and more secure without entering a password, you can generate a public/private SSH key pair and upload the public key to each node.
On your local machine, check whether the $HOME\.ssh directory contains the files id_ed25519 and id_ed25519.pub. If you do not have the key pair, generate it by running the following command on your machine:
You will be prompted for a passphrase, which you can leave empty if you do not need the extra layer of security.
When completed, the id_ed25519 and id_ed25519.pub files are added to the .ssh directory ($HOME\.ssh on Windows or ~/.shh on Linux and Mac).
Then copy the public key to each node, using one of the following commands.
For Windows (Powershell):
For Linux or macOS (Bash/Zsh):
If you do this for each node, you will not be prompted for the password anymore. You can now disable the SSH access to the nodes through a username and password for security reasons.
Creating SSH Connection Shortcuts
You can simplify the SSH access by defining aliases for each node. You need to create a configuration file named $HOME\.ssh\config on Windows or ~/.ssh/config on Linux and MAC and enter the aliases there. The following example shows three nodes with aliases n1, n2, and n3.
When successfully completed, you can access the nodes using the following shortcuts:
-
ssh n1
-
ssh n2
-
ssh n3
What's Next?