Connect Linux Server via Jump Host in Ansible
When managing remote systems with Ansible, connecting to a Linux server through a jump host is a common and secure method. This setup provides an additional layer of security, ensuring your communication between the Ansible controller and target server remains protected.
In this guide, we will show you how to set up an Ansible controller to securely connect to a target Linux server via a jump host, making your automation processes more efficient and secure.

What Is a Jump Host?
A jump host serves as an intermediary server that allows secure access to a remote machine. This is particularly useful when you need to access servers in a protected network or behind a firewall. By connecting through a jump host, you can ensure that your connection to the Linux server remains secure.
Jump hosts should always be hardened for security purposes. Using an unprotected machine as a jump host can introduce significant security risks, so make sure to implement necessary hardening steps.
Prerequisites for Setting Up Linux Server via Jump Host in Ansible
Before proceeding, ensure that you have the following components in place:
- Ansible Server (version 2.9 or higher)
- Linux Jump Host with SSH access enabled
- Target Linux Server to be managed by Ansible
- SSH keys for secure access from the Ansible server to the jump host and from the jump host to the target server
Step 1: Generate SSH Keys on the Ansible Server
The first step is generating SSH keys on the Ansible server to allow secure communication with the jump host.
- On the Ansible server, run:
[root@ansible ~] ssh-keygenChoose the default location for the key and add a passphrase if needed. - Copy the public key to the jump host:
[root@ansible ~] ssh-copy-id root@192.168.0.35Replace 192.168.0.35 with your jump host’s IP address.
Step 2: Generate SSH Keys on the Jump Host
Next, generate the SSH key pair on the jump host to allow secure connections to the target server.
- On the jump host, run:
[root@jump ~] ssh-keygenSave the key and optionally set a passphrase. - Copy the public key to the target Linux server:
[root@jump ~] ssh-copy-id zippyops@192.168.0.71Replace 192.168.0.71 with your target server’s IP address.
Step 3: Manage SSH Key Security
To improve security, use different user accounts for each step of the connection process. For instance, use user1 to connect from the Ansible server to the jump host, and user2 for connections from the jump host to the target server.
Also, export the jump host’s private key to the Ansible server to ensure that the correct credentials are used during operations.
[root@jump ~] scp id_rsa root@192.168.0.143:/home/zippyops/id_rsa
Here, 192.168.0.143 is the Ansible server’s IP address.
Step 4: Configure Ansible to Use SSH Keys
Now, configure the Ansible setup to use the appropriate SSH keys and users for the connections. Edit the Ansible configuration file (/etc/ansible/ansible.cfg) to specify the path to the private key.
- Specify the private key file path in the configuration.
- Define the
ansible_ssh_userin the host variables to specify which user to use when connecting from the jump host to the target server.
Example:
[all]
target-server ansible_host=192.168.0.71 ansible_ssh_user=user2
Step 5: Test the Setup
Once you’ve configured everything, test the setup by running the following Ansible commands:
ansible all -i hosts_test -m ping
ansible all -i hosts_test -a "/usr/bin/uptime"
If the configuration is correct, you should see successful responses from the target server.
Boost Your DevOps with ZippyOPS
If you’re looking to enhance your DevOps workflows, ZippyOPS offers comprehensive services in DevSecOps, Cloud management, DataOps, and more. We specialize in optimizing Automated Ops, AIOps, MLOps, and microservices for seamless integration and increased operational efficiency.
Explore our services and solutions to learn more. For detailed consulting or custom implementations, don’t hesitate to reach out to us at sales@zippyops.com.
Conclusion on Linux server to connect through a jump host
Setting up a Linux server to connect through a jump host in Ansible is an excellent way to enhance your network security while managing remote machines. By following the SSH configuration steps and ensuring secure key management, you can optimize your automation workflows.
Ready to take your automation and infrastructure management to the next level? Contact ZippyOPS for expert solutions tailored to your needs.



