- 
      
- 
        Save jinoj/b94bddb0c350befd76b79a329b5d9bdb to your computer and use it in GitHub Desktop. 
    Ansible SSH Agent forwarding with Jump (bastion) host
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | [defaults] | |
| sudo_flags = SSH_AUTH_SOCK="$SSH_AUTH_SOCK" -H -S -n | |
| [ssh_connection] | |
| ssh_args=-o ForwardAgent=yes | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | ControlMaster auto | |
| ControlPath ~/.ssh/tmp/control_%h_%p_%r | |
| ControlPersist 1m | |
| Host jump | |
| HostName <jump_ip> | |
| User nazarewk | |
| ForwardAgent yes | |
| Host secured-* | |
| User nazarewk | |
| ## ProxyJump works on OpenSSH 7.3+ (newest version as of 16.09.2016) | |
| # ProxyJump jump | |
| ProxyCommand ssh jump -W %h:%p | |
| ForwardAgent yes | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | - name: Ensuring we can ForwardAgent | |
| lineinfile: | |
| dest: "~/.profile" | |
| line: '[ -n "$SSH_AUTH_SOCK" ] && setfacl -m u:{{ project_user }}:rw "$SSH_AUTH_SOCK" && setfacl -m u:{{ project_user }}:x "$(dirname $SSH_AUTH_SOCK)"' | |
| insertafter: EOF | |
| - name: Ensure we have ForwardAgent | |
| command: ssh-add -l | |
| become: true | |
| become_user: "{{ project_user }}" | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment