Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ssh keyscan with username #2667

Closed
antonmedv opened this issue Sep 23, 2021 Discussed in #2666 · 5 comments · Fixed by #2668
Closed

ssh keyscan with username #2667

antonmedv opened this issue Sep 23, 2021 Discussed in #2666 · 5 comments · Fixed by #2668

Comments

@antonmedv
Copy link
Member

Discussed in #2666

Originally posted by underdpt September 23, 2021
Hello,

With v7.0.0-beta25, this setup:

set('repository', 'ssh://[email protected]:2233/folder/project.git');
set('ssh_multiplexing', PHP_OS_FAMILY === 'Windows' ? false : true);
set('default_timeout', null);

host('my.server.host')
    ->set('labels', ['stage' => 'production'])
    ->set('branch', 'master')
    ->set('remote_user', 'mainsip')
    ->set('port', 2223)
    ->set('deploy_path', '/var/www/project');

produces this error:

info deploying master
task deploy:setup
task deploy:lock
task deploy:release
task deploy:update_code
[my.server.host]  error  in update_code.php on line 54:
[my.server.host] run ssh-keyscan -p 2233 -H [email protected] >> ~/.ssh/known_hosts
[my.server.host] err getaddrinfo [email protected]: Name or service not known
[my.server.host] err getaddrinfo [email protected]: Name or service not known
[my.server.host] err getaddrinfo [email protected]: Name or service not known
[my.server.host] err getaddrinfo [email protected]: Name or service not known
[my.server.host] err getaddrinfo [email protected]: Name or service not known
[my.server.host] exit code 1 (General error)

I think the error might be that the hostname is including the user part git@... for the ssh-keyscan command.

This works with v7.0.0-beta24

@Sander-Toonen
Copy link
Contributor

Sander-Toonen commented Sep 23, 2021

if (preg_match('/(?:@|\/\/)([^\/:]+)(?:\:(\d{1,5}))?/', $repository, $matches)) {

This regex is too naïve. It will also fail when the repository is pulled over http, in which case key-scanning makes no sense. I would suggest using parse_url. Then only do the keyscanning when the scheme equals "ssh" and use the "host" component. Any thoughts on that?

@antonmedv
Copy link
Member Author

Can you create a PR with a fix?

@Sander-Toonen
Copy link
Contributor

Coming up...

Sander-Toonen added a commit to Sander-Toonen/deployer that referenced this issue Sep 23, 2021
antonmedv pushed a commit that referenced this issue Sep 23, 2021
… url (#2668)

* Use PHP biuld in funtion to detect scheme, hostname and port in repo url. refs #2667

* Updated changelog

* Add missing reference to changelog

* Unrelated issue, in order to make phpstan happy.
@Sander-Toonen
Copy link
Contributor

Sander-Toonen commented Sep 23, 2021

Could you please release a new beta? This issue is breaking quite some pipelines and downgrading is not possible due to #2592.

@antonmedv
Copy link
Member Author

Released beta.26

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants