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

Always specify ssh port when using ghe-ssh #102

Merged
merged 1 commit into from
Feb 12, 2015
Merged

Conversation

lildude
Copy link
Member

@lildude lildude commented Feb 12, 2015

If a user doesn't specify a port, backup-utils makes assumptions based on the successful connection test at https://github.com/github/backup-utils/blob/master/bin/ghe-host-check#L27

The problem with this is if a user adds an entry to their ${HOME}/.ssh/config similar to:

Host ghe.example.com
    Port 122       # <----- This is the pertinent part
    User admin
    IdentityFile /Users/username/.ssh/id_rsa

... this test thinks the connection was made on port 22, when it was actually on port 122, and the restore fails as follows:

$ bin/ghe-restore ghe.example.com
Connect ghe.example.com:22 OK (v2.1.2)
Starting restore of ghe.example.com:22 from snapshot 20150201T144744
Restoring settings ...
Restoring license ...
Restoring Git repositories ...
ssh: connect to host ghe.example.com port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at /SourceCache/rsync/rsync-45/rsync/io.c(453) [sender=2.6.9]

... forcing people to explicitly specify a port in their backup.config or in the hostname they pass as an argument.

This PR removes this assumption and forces the explicit setting of a port in all SSH commands thus catching this scenario.

As GitHub Enterprise only accepts connections on port 22 and 122 with no option of customising this, I think this is a safe thing to do. Even if someone does change this to some obscure port in the future, the processing of the port passed in via the argument or config continues to work.

@rtomayko
Copy link
Contributor

👍 Looks great.

I wanted to verify we weren't going to accidentally pass -p without a value. The ssh_port_part function used by ghe-ssh always returns a port number so we should be good there:

https://github.com/github/backup-utils/blob/always-use-ssh-port/share/github-backup-utils/ghe-backup-config#L230-L235

rtomayko added a commit that referenced this pull request Feb 12, 2015
Always specify ssh port when using ghe-ssh
@rtomayko rtomayko merged commit 3ba7048 into master Feb 12, 2015
@lildude lildude deleted the always-use-ssh-port branch February 12, 2015 16:09
snh added a commit that referenced this pull request Aug 7, 2017
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 this pull request may close these issues.

2 participants