OS X SSH connect to host operation timed out - ssh

When running
ssh -v myuser#xx.xxx.xxx.xx
I connect to the server and can operate the session
When running
ssh myuser#xx.xxx.xxx.xx
the behaviour returns
ssh: connect to host xx.xxx.xxx.xx port 22: Operation timed out
THis behaviour appeared after I stated on the server:
ssh-add ~/.ssh/id_rsa
thus adding the id to the agent has messed up ssh... How to fix?

Related

Unable to connect to gitlab, Connection timed out

I have created ssh keys on unbuntu under id_company and id_company.pub, and updated config as:
Host gitlab.company.com
Hostname gitlab.company.com
#PreferredAuthentications publickey
IdentityFile ~/.ssh/id_company
Now, I am trying to test the connection using: ssh -T git#gitlab.company.com, But I am receiving ssh: connect to host gitlab.company.com port 22: Connection timed out I don't know what might be causing it, or am I doing something wrong?
Make sure first your gitlab.company.com server is accessible through port 22:
curl -v telnet://gitlab.company.com:22
I know in my company, no SSH access would ever be granted: HTTPS only.

SSH remote port forwarding through bastion server

I'm trying to establish a remote port forwarding to my Mac (target 4004) via a bastion host and Server-A to a Port (1555) on Server B.
So the whole connection is:
Mac:4004 => Bastion:22 => A:22 => B:1555
And the target is my Mac should have a Port 4004 forwarded from B:1555.
What is working so far?
I can connect to Server A with the command ssh user-bastion#user-A#server-A#server-bastion
On Server A I can establish a connection e.g. telnet to B:1555
On my windows client I can remote forward the port B:1555 to my local machine via Putty.
I'm now looking for the ssh command to establish this connection on my Mac.
Commands I tried:
Of course I have already searched for it and I've already tried different versions.
e.g.
ssh -fNT -R 1555:localhost:4004 -J user-bastion#user-A#server-A#server-bastion server-B
ssh -N user-bastion#user-A#server-A#server-bastion -R server-B:1555:localhost:4004
I always receive message like "Warning: remote port forwarding failed for listen port 1555"

ssh: connect to host {IP Address} port 22: Operation timed out

I was setting up a firewall with UFW in Ubuntu server, I skipped the step sudo ufw allow ssh and instead run the command sudo ufw enable. Rebooted the VPS but now when I try to connect using ssh, I get the following error ssh: connect to host {IP Address} port 22: Operation timed out.
I am using Google Cloud Compute Infrastructure and I'm not understanding details in this article https://cloud.google.com/compute/docs/ssh-in-browser#ssherror
Is there a way I can rollback?
You can login to your instance using the serial console. After logging in you should run the command: sudo ufw allow ssh, for allowing ssh access to your instance.
See Interacting with the Serial Console for more information

SSH works fine with .ssh/config, but fabric breaks

I have an .ssh/config:
Host host01 host01.in.mynet
User costello
HostName 1.2.3.4
Port 22222
Which is working fine with plain ssh:
ssh host01
costello#host01 ~ ยป
But fabric is not using that config:
$ fab deploy:host=host01
[host01] Executing task 'deploy'
Fatal error: Low level socket error connecting to host host01 on port 22: Connection refused (tried 1 time)
Underlying exception:
Connection refused
Aborting.
Why is fabric not using the ssh's configuration? I would really like to avoid duplicating the configuration for fabric or, even worse, change the ssh port of my server.

SSH tunnel stops working after EC2 instance restart

I have an SSH tunnel from an EC2 instance (say A) to another with an Elastic IP (say B). It worked perfectly. Yet, B had a failure. So I had to stop it, and start a new instance with the same Elastic IP. And now the exact same SSH tunnel does not work anymore. Yet:
I can still SSH from A to B. So I know my keys are in place
I tried the exact same tunnel from another instance than A, and it works as expected.
So somehow, it is as if A detected a problem when B went down, and it is now blocking the traffic.
Tunnel:
/usr/bin/ssh -o StrictHostKeyChecking=no -i /path_to/id_dsa -f -p 22 -N -L 26:www.foo.com:80 ssh_tunnel#amazon_public_ip
And when I try Curl here is what I get:
curl -v -H "Host: www.foo.com" http://localhost:26/foofoo
* Hostname was NOT found in DNS cache
* Trying 127.0.0.1...
* connect to 127.0.0.1 port 26 failed: Connection refused
* Failed to connect to localhost port 26: Connection refused
* Closing connection 0
curl: (7) Failed to connect to localhost port 26: Connection refused
Am I missing something?
I found the issue. I did not pay attention, but when I was SSH-ing into the instance, I was getting a warning message: WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!. Since it worked anyway, I thought it was not a problem. It turns out it makes the tunnel fail.
So I just removed the offending RSA key from known_hosts and now it works.