Use SSH on Linux/Unix Nodes
Use SSH on Linux/Unix Nodes
Rundeck allows users to dispatch jobs to remote Linux/UNIX servers to manage and automate any task using Rundeck workflows. The most common protocol for connecting to Linux/Unix servers is SSH. This is an example of how to add a remote node and configure Rundeck to use SSH to connect to it.
Note: If this is the first time adding remote nodes. It is suggested to review the Rundeck Tutorial before adding remote SSH nodes. This exercise assumes some experience with Linux, SSH Keys, and Rundeck basics covered in the Tutorial.
Warning
This documentation is for use with the Welcome Projects on non-production instances. It is strongly recommended to follow best practices when generating, managing and configuring SSH keys and access. For detailed configuration of SSH use this documentation.
Configuring Rundeck
Rundeck can store the authentication keys necessary to authenticate to our Linux example host in Rundeck’s built-in Key Storage.
- Click on the System Menu (gear icon) and choose Key Storage.
- Click on the Add or Upload a Key button to create a New entry in the Rundeck Key Storage.
- For Key Type select
Private Key
. - Add Rundeck instance private key file content in Enter text. The key is located at
/var/lib/rundeck/.ssh/id_rsa
. - In the Storage path field it’s possible to define specific subfolders for the keys if needed, for this example just leave it blank.
- In the Name textbox enter a key name that corresponds to the Rundeck host, in this example is just
rundeck
(now the Key Storage entry iskeys/rundeck
).
Adding Nodes
Now, it’s time to add the remote node.
Included in Enterprise is the Node Wizard Node Source. Use that to add a new node by following these steps:
- Click Project Settings | Edit Nodes
- Click the Modify button under the Node Wizard entry.
- Click + Add Node.
- Set the Node Name to
node1
- Set HostName to
node1
- Set OS Family to
Unix
- Click the Authentication Tab at the top.
- Enter
agent
for the UserName. - Click Add Node to save that node entry.
- Click the Save button under the list of nodes.
Rundeck Community
- Click Project Settings | Edit Nodes
- Click on the Add new Node Source button.
- There will be a list of options, select the File Node Source.
- In the drop-down menu on the right, select resourceyaml.
- In File Path choose a path reachable by the Rundeck user - e.g: in the
/var/lib/rundeck/resources.yml
directory. It’s important to leave the filename at the end, otherwise, it will not be created. - Next, check Generate, Include Server Node and Writeable.
- Finally, click on the Save button. The file will be added to the server and ready for a node entry.
Once created, the file can be edited by clicking on the "Modify" button (Edit tab) where we can add an extra entry corresponding to our remote SSH server.
Use the following resources.yaml
file content:
remote-node:
description: Remote SSH server node
hostname: node1
nodename: node1
osArch: amd64
osFamily: unix
osName: Linux
osVersion: 5.11.0-7612-generic
tags: 'node1'
username: agent
ssh-key-storage-path: keys/rundeck
In the hostname attribute, place the DNS name of our remote node. In username the user who is trying to access the SSH server, In ssh-key-storage-path specifies the path that was created in key storage earlier.
Running Commands on Nodes
Let’s dispatch some commands!
- Clicking on the "Nodes" tab (left menu) and using the drop-down to choose Select All Nodes will display all the nodes that have been configured. The screenshot below shows the listing with 2 nodes (the Rundeck node and the node added recently).
- To select the node created earlier, put the name in Nodes textbox; In this case,
node1
and press Enter key, now the node is selected. - In the Enter a command textbox put a command, e.g.:
df
, and click on the Run on 1 Node green button.
Congratulations! A remote SSH node to dispatch commands and jobs is setup in Rundeck. Stay tuned to the next blog entry where we build a job to execute on this Node.