deployer icon indicating copy to clipboard operation
deployer copied to clipboard

Docs: add an example with bastion server

Open antonmedv opened this issue 1 year ago • 2 comments

          An example with bastion server
host('10.10.10.30')
    ->stage('prod')
    ->user('deploy')
    ->roles('app')
    ->set('deploy_path', '/site')
    ->addSshOption('ProxyCommand', '"ssh -W %h:%p -q user@bastion"');

Originally posted by @alinalexandru in https://github.com/deployphp/deployer/issues/223#issuecomment-1489168848

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar

antonmedv avatar Mar 29 '23 19:03 antonmedv

Posibile workaround in V7, until the API is changed in V8

In deploy.php use the option config_file


host('web.xxxx.xxxxx')
    ......
    ->set('config_file', 'ssh/config');

Create file ssh/config where all the ssh options are specified

Host jumphost
    HostName xxx.xxx.xxx.xxx
    User xxxxx
    # Optional. Depending an your setup
    StrictHostKeyChecking no 

Host web.xxxx.xxxxx
    HostName xxx.xxx.xxx.xxx
    User xxx
     # Optional. Depending an your setup
    StrictHostKeyChecking no
    ProxyJump jumphost

alinalexandru avatar Dec 21 '23 08:12 alinalexandru

Did the following using ssh config provided to a Gitlab Runner, to access target-server through bastion server.

@alinalexandru should we update DeployerPHP documentation somewhere ?

~/.ssh/config :

Host *
    Forwardagent yes
    StrictHostKeyChecking no
    AddKeysToAgent yes

Host bastion
    IdentityFile ~/.ssh/key
    HostName bastion.example.com
    User bastion

Host target-server
    HostName ip
    Port port
    IdentityFile ~/.ssh/key 
    ProxyCommand ssh -W %h:%p bastion
    User exampleUser

hosts.yml :

hosts:
  env-name:
    hostname: target-server
    stage: stageName
    branch: branchName
    deploy_path: /var/www/html
    ssh_arguments: ['-o StrictHostKeyChecking=no' ]

gbobts avatar Mar 29 '24 11:03 gbobts