I think this may be a problem with your public/private keypair. I am having the same issue. I opened up the file mentioned “C:/aptible-toolbelt/embedded/lib/ruby/gems/2.3.0/gems/aptible-cli-0.19.6/lib/aptible/cli/helpers/tunnel.rb” and navigated to line 46. It is ultimately opening up an ssh connection but failing to do so. I added a print statement for the command params as seen in the code below
tunnel_cmd = @ssh_cmd + [
'-L', "#{@local_port}:#{@socket_path}",
'-o', 'ExitOnForwardFailure=yes'
]
#print contents of tunnel_cmd
print(tunnel_cmd)
out_read, out_write = IO.pipe
err_read, err_write = IO.pipe
@pid = Process.spawn(@env, *tunnel_cmd, SPAWN_OPTS
.merge(in: :close, out: out_write, err: err_write))
This gave me output similar to this:
["ssh", [dynamically-generated-user]@[system-generated-name]", "-p", "1022", "-i", "C:/Users/[my-username]/AppData/Local/Temp/d20230126-23620-o2mpt5/id_rsa", "-o", "IdentitiesOnly=yes", "-o", "UserKnownHostsFile=C:/Users/[my-username]/AppData/Local/Temp/d20230126-23620-zas3rk/known_hosts", "-o", "StrictHostKeyChecking=yes", "-T", "-o", "TCPKeepAlive=yes", "-o", "KeepAlive=yes", "-o", "ServerAliveInterval=60", "-o", "LogLevel=ERROR", "-o", "ControlMaster=no", "-o", "ControlPath=none", "-F", "C:\\Users\\cestel/.aptible/ssh/config", "-o", "SendEnv=ACCESS_TOKEN", "-L", "60699:/var/run/port-forward/c5ef3ca7-3ff1-4682-a46f-46cac336d530", "-o", "ExitOnForwardFailure=yes", "-vvv"]Tunnel did not come up: C:/aptible-toolbelt/embedded/lib/ruby/gems/2.3.0/gems/aptible-cli-0.19.6/lib/aptible/cli/helpers/tunnel.rb:47: warning: cannot close fd before spawn
From there, I was able to pull the components out and stitch together a standard ssh command. Substitute accordingly from the values above.
ssh [username-from-above]@[host-from-above] -p 1022 -i ~/.aptible/ssh/id_rsa -o IdentitiesOnly=yes -o SendEnv=ACCESS_TOKEN -L 57473:/var/run/port-forward/f53ddd86-1fc3-478f-b21d-290cbd02390c
You could be thorough and add every field, but the ones I used above should be good enough to find your issue.
The output when trying to connect with raw ssh was this below:
[user-from-above]@[host-from-above]: Permission denied (publickey).
I still have not been able to correct or connect. My public key was uploaded to my ssh keys section. I attempted to create a new key and upload that and was still unsuccessful in establishing a connection. I then attempted to delete my keys and re-upload them in aptible. It let me delete them but then was giving me a system error when trying to re-add them from the website. I assume I may have hit some sort of excess failure limit with my user or something and plan to wait it out and try again, but it definitely seems key related.
An issue with the key would make sense as the code appears to be failing to open the connection and is closing something that wasn’t open. Even though (at time of writing) I haven’t solved this, I think it’s likely the issue and hopefully helps. If anyone else wants to see how things work with a bad private key, I suspect you can use that to replicate the issue.