How to push to heroku behind a proxy? - proxy

I am using git behind a proxy server at my university. While trying to execute
git push heroku master
I get an error
ssh: connect to host proxy.heroku.com port 22: Bad file number
fatal: The remote end hung up unexpectedly
I had a similar problem when pushing to git earlier, but that was solved using their smart HTTP. From what I've read so far, it seems to be a network problem. How do I fix this? Is there any way to push to heroku using HTTP? (I'm guessing pushing through SSH is causing this problem and that the port 22 is blocked)

Corkscrew is a tool for tunneling SSH through HTTP proxies
Setting up Corkscrew with SSH/OpenSSH is very simple. Adding
the following line to your ~/.ssh/config file will usually do
the trick (replace proxy.example.com and 8080 with correct values):
ProxyCommand /usr/local/bin/corkscrew proxy.example.com 8080 %h %p
Follow http://www.agroman.net/corkscrew/README

Heroku only supports git pushes over SSH (port 22) - it's likely that your university is preventing outbound port 22 access which causes your push to fail.

Related

How to specify ssh custom port in GitKraken on Windows?

I'm running a Gitkraken client on Windows 10. I've a remote GitLab (self-hosted) server listening SSH on port 2222. It seems, i can't use an SSH, whatever i tried to :
Clone Failed
Configured SSH key is invalid.
Please confirm that it is properly associated with your Git provider.
After some digging, it seems Gitkraken doesn't read my ssh config file witch specify my custom ssh port (Sourcetree works just fine).
How do I specify my ssh custom port in GitKraken ?

"network error: connection refused", putty error

I am trying to run putty on Windows 7.
I need to run some SSH commands to upgrade Magento. Every time putty gives me this fatal error:
network error: connection refused
I have even tried to use it through winSCP. Note that putty is running fine on my client's side, but for me it's giving me that error every time.
I tried using port 22, 23 and a few others without success. I have also tried with Windows Firewall both enabled and disabled.
Thank you.
Install open-ssh or ssh in target Linux machine solved my problem .
Use below commands:
sudo apt install ssh
sudo systemctl status ssh
sudo systemctl enable ssh
The following are the list of possibilities of this error:
1) Common cause is - Your IP is blocked or not whitelisted in the server which can be done by editing the file at /etc/csf/csf.conf
2) Disable the windows firewall settings and check..
The above two things should work in most of the cases
3) This is very unusual and when the above two options fails it is very difficult to find the solution
In this case the traceroute to the server host or IP works usually but putty fails
port 22 looks normal and working but connection fails and restarting SSH (service ssh restart) also does not work
reboot or restart the server but still fails
Adding IP in firewalls or whitelisting the local IP may not workout
This case generally happens when the server is migrated or new server. IP of the old server might be whitelisted locally, but don't have port 22 open, or some other local filtering is occurring for this new IP but not the old server IP..
In this case you need to change the port to some 522 or 530 some unusual port will help in sorting it out.. The same port you have to use for the SFTP connection also .. where as FTP connections works normally..
or you have to whitelist the IP locally or open the TCP in and out to port 22 if you want to use the port 22..

Connecting to Heroku using port 443

I'm a university student and all ports except 80, 443 are blocked. I'm able to connect to github via
Host github.com
Hostname ssh.github.com
Port 443
git push heroku master gives me this error:
ssh: connect to host heroku.com port 22: Connection refused
fatal: The remote end hung up unexpectedly
I've tried the solutions posted here on SO but I've still not got it working. Is there a way I can connect to heroku do deploy my websites?
Thanks a lot
Heroku ssh only works over port 22. There is, however, a plugin that lets you push via HTTP. It does not use git, though. Instead, you heroku push.
https://github.com/ddollar/heroku-push
If your SSH port been blocked and wish to push into heroku using alternate port then you may consider Tunneling.
For tunneling you are required to have additional PC or Server resides outside of blocked network and having access to Port 22.
For the scenario below we can use house PC to tunnel into heroku server. Since the university network only allow Port 80 and 443, we can set the House PC to receive connection via port 443 and tunnel it to port 22.
At House PC:
Configure SSH server in the house PC to run on port 443. Refer here to configure SSH Server on Multiple Ports
University PC:
Configure University PC to resolve git_tunnel alias to point to localhost on port 9001. Edit ~/.ssh/config and add following
# ~/.ssh/config
Host git_tunnel
Hostname 127.0.0.1
User git
Port 9001
Add a new remote alias as tunnel which will point to git#git_tunnel:{app name}.git
git remote add tunnel git#git_tunnel:{app name}.git
From the University PC establish tunnel to house PC which listening on port 443.
ssh -L 9001:heroku.com:22 -p 443 root#housepc.com
Deploy to heroku using alias tunnel created earlier
git push tunnel master

ssh: connect to host heroku.com port 22: Connection timed out

I am working on Ubuntu 11.10
Local branch of my git-repo is up to date
I then wrote following command in terminal: heroku create --stack cedar and it said:
Notice: on Wed, 20 June, our default stack will change to Cedar. http://bit.ly/Lh0rM5
Creating radiant-wind-7413... done, stack is cedar
http://radiant-wind-7413.herokuapp.com/ | git#heroku.com:radiant-wind-7413.git
Git remote heroku added
All fine till now, then I typed following in terminal:
git push heroku master
and the following error occured:
ssh: connect to host heroku.com port 22: Connection timed out
fatal: The remote end hung up unexpectedly
As of November 30, 2021, the SSH Git Transport feature has been deprecated by Heroku and only HTTP transport is supported. The real shutdown of SSH was in March 2022.
You have to reconfigure the repo with :
heroku git:remote -a <app-name>
Official statement from Heroku
If you are using a remote with a different name, e.g. production then use
heroku git:remote -a <app-name> -r <remote-name>
Maybe you will have to unset ssh connections on git global config :
git config --global --unset url.ssh://git#heroku/.insteadof
git config --global --unset url.ssh://git#heroku.com/.insteadof
Most probably some sort of firewall issue or your network admin has blocked outgoing port 22 in your network.
You may use simple scrip to see your connection to Heroku by :
$ ssh -vvv git#heroku.com
If you seeing connect timed out then you may need to request your admin to unblock port 22. Alternatively may access Heroku via tunneling as per my answer in Connecting to heroku using port 443
I had the similar problem with keys. Ok this is what I did.
Check the status of your keys with
heroku keys
It shows you list of keys that are added to heroku. You can always generate new keys and add them to heroku.
ssh-keygen -t rsa
Generates new key.
heroku keys:add
adds the keys to heroku. Before adding it lists the available keys that you can add. Enter the option and you key is added to heroku.
This article can be helpful. If that doesn't work then there should be some problem with ssh. Try doing an ssh localhost and see if ssh is working.
Today Heroku uses git over ssh. The default port for ssh is 22 and it looks like your network doesn't allow outbound connections to port 22. Perhaps this is something your network administrator can change.
I had been working on this for hours trying to figure out how I could suddenly have a closed port 22, etc. when literally 5 hours ago everything was working and nothing had changed.
Finally I just reset my Git repo on Heroku and repushed everything. Still no idea what happened.
heroku plugins:install heroku-repo
heroku repo:reset --app appname
Do following steps.
ssh-keygen -t rsa
heroku keys:add
heroku keys # lists keys
For me helped destroying whole app and recreating again - leaving it here for future reference.
heroku apps:destroy appname
heroku apps:create appname
heroku git:remote -a appname
git push heroku master
I added the https url to the .git/config file in my project folder. I found the HTTPS URL in the project Settings on Heroku. I then added that URL to replace the SSH url inside the .git/config text file.

Setting openssh port in windows for msysgit

A quick question. I am using msysgit with openSSH as a git client. i don't want to use other ssh clients such as putty. From GIT Bash I have succesfully connected to my server with ssh -p XXXX to my sever.
Unfortunately when i try to do something like:
git clone git#SERVER:reponame.git
from the Git Bash I get:
ssh: connect to host SERVER port 22 failed.
How can I make the ssh connection that msysgit tries to open with openssh run at a different port?
I know that in linux such a thing would be in /etc/ssh/ssh_config file but how would I go about doing that in this case? Thanks in advance.
git supports the following syntax for ssh://
ssh://[user#]host.xz[:port]/path/to/repo.git/
Note the port in there.

Resources