“...I've been working since 2008 with Ruby / Ruby on Rails, love a bit of Elixir / Phoenix and learning Rust. I also poke through other people's code and make PRs for OpenSource Ruby projects that sometimes make it. Currently working for InPay...”

Rob Lacey
Senior Software Engineer, UK

Capistrano Deployment to server with non-standard SSH port

I recently changed the default SSH port of one of my client’s servers. It appears that the first time I tried to deploy via Capistrano it hanged and I had to kill the task.

export GIT_ASKPASS="/bin/echo" GIT_SSH="/tmp/somerepo/git-ssh.sh" ; /usr/bin/env git ls-remote git@github.com:someuser/somerepo.git

I added the GIT_SSH_COMMAND export to give some debug.

export GIT_SSH_COMMAND="ssh -vvv" export GIT_ASKPASS="/bin/echo" GIT_SSH="/tmp/somerepo/git-ssh.sh" ; /usr/bin/env git ls-remote git@github.com:someuser/somerepo.git

It appears to be connecting on the custom port for that new server.

export GIT_SSH_COMMAND="ssh -vvv" export GIT_ASKPASS="/bin/echo" GIT_SSH="/tmp/somerepo/git-ssh.sh" ; /usr/bin/env git ls-remote git@github.com:someuser/somerepo.git
OpenSSH_6.9p1, OpenSSL 1.0.2d 9 Jul 2015
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to github.com [192.30.253.112] port 1234.

So for some inexplicable reason it’s trying to forward using the same port as the initial connection is made from. I can’t find an option to turn this off in the Capistrano 3 config so I am going to force the port to be 22. Editing ~/.ssh/config on the server with the following fixes it. Be sure if this is a new file to chmod permissions to 644.

Host github.com
Port 22
GPK of the Day Bad Breath SETH