I have been struggling to push from travis back into github for too long. I have the build- linked above. It does ‘stuff’ and then at the very end of the build it will mutate a file (version info) and try to commit/push that file back to github.
I’ve tried everything but I can’t get it to work yet. the build basically will:
grab a private key from an environment variable
tell git to use that key as part of the sshCommand
update the url to be git@ vs https://
git add, git commit -m “[skip ci]” (a nice travis feature), and finally a git push
the push fails no matter what i do - i added an ssh -Tv git@github.com to see what that might tell me and it seeeeems like travis doesn’t have a proper entry in known_hosts? Here’s that snippet:
issuing ssh -vT -i github_deploy_key git@github.com
OpenSSH_8.3p1, OpenSSL 1.1.1g 21 Apr 2020
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to github.com [140.82.113.4] port 22.
debug1: Connection established.
debug1: identity file github_deploy_key type 0
debug1: identity file github_deploy_key-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.3
debug1: Remote protocol version 2.0, remote software version babeld-5a455904
debug1: no match: babeld-5a455904
debug1: Authenticating to github.com:22 as 'git'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: rsa-sha2-512
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ssh-rsa SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8
debug1: read_passphrase: can't open /dev/tty: No such device or address
Host key verification failed.
you can see on those last three lines “Host key verification failed” Surely this is doable - I must have missed something but I’ve tried everything to get it to work. I’ve issued
This still doesn’t work for me and it’s still unclear as to why. you can see in the raw log here that the following was run by travis on my behalf because of these lines in my .travis.yml
[0K$ ssh-keyscan -t $TRAVIS_SSH_KEY_TYPES -H git.savannah.nongnu.org 2>&1 | tee -a ${TRAVIS_HOME}/.ssh/known_hosts
...
[0K$ ssh-keyscan -t $TRAVIS_SSH_KEY_TYPES -H github.com 2>&1 | tee -a ${TRAVIS_HOME}/.ssh/known_hosts
This suggests that it tries to read the password for SSH connection, interactively. Of course, this is impossible in a non-interactive build.
What are you trying to do here? Could you reference some documentation on that process? Because I’m not sure if whatever you are trying is supposed to be possible.
AFAICS, you are using some 3rd-party program instead of Travis’ built-in facilities to upload some artifact… somewhere. In this case, that program’s maintainers are going to be better positioned to tell you how to use it.
The last idea I have is that 3rd-party program seems to be trying to unshallow your local repo clone. You can make that step unnecessary as per Customizing the Build - Travis CI
git:
depth: false
hopefully, that will stop that program from trying to do whatever it is failing at and allow it to proceed further.
at the very end of the build it will mutate a file (version info) and try to commit/push that file back to github.
So I am trying to mutate a file, and push it back into my repository from travis. Travis has a mechanism to add keys to known hosts - which I’ve used. I’ve also tried to work around travis. Effectively everything I do appears to be failing from a windows-based travis build because the ssh command is not finding github in the knownhosts file.
@Montana gave me a command to try - in order for this to clear travis but I’d already done that as well as tried to use the built-in way of doing the same via travis.
The 3rd party program is just ‘git push’ using an ssh key.
The depth: false tip is appreciated. I might try that just to see what happens if I avoid Travis’ shallow clone.
After a very lengthy break from this topic I finally backed up far enough to figure out what went wrong and why. As with most bugs - it’s notoriously simple. I do think this is a bug with Travis though.
Here’s what fixes this issue when trying to push from windows using an ssh key… Create the .ssh folder in %USERPROFILE% and then add github to known_hosts. Here’s how I did it:
@echo mkdir %USERPROFILE%\.ssh and add github.com to known_hosts... 2>&1
mkdir %USERPROFILE%\.ssh 2>&1
@echo adding github key: ssh-keyscan -t rsa github.com 2>&1
ssh-keyscan -t rsa github.com >> %USERPROFILE%\.ssh\known_hosts 2>&1
@echo looking for key using: ssh-keygen -F github.com - expect to find it now! 2>&1
ssh-keygen -F github.com 2>&1
@Montana - I see you are a Travis employee - should I file this as a bug (or do you?) I’d file a bug saying the ‘addon’ does not work: