How to identify established but inactive SSH tunnel - powershell

I created a reverse SSH tunnel from a public server to my local Windows Machine. It works properly and I can access my local machine. However, due to internet disruption, the tunnel disconnects but doesn't come up when internet connectivity resumes. I checked on windows that the ssh process was still running and the connection was shown established.
>> Get-Process ssh | select -expandproperty ProcessName
ssh
Get-NetTCPConnection also showing Established Internet on port 22.
The tunnel is though not accessible from public server
$ ssh user#localhost -p 2000
ssh: connect to host localhost port 2000: Connection refused
How can I identify whether SSH tunnel is inactive or not so that I can kill it and restart new. Any command line solution will do for me except autossh as its not available for windows.

Related

Is there any possibility to establish a SSH tunneling from the server using the postgresql to the client

I have one server machine where PostgreSQL and SSH server is installed. I have another client machine from where i want to connect to the PostgreSQL on the server machine in a secure way. I used SSH tunnel which is working.
I tried to connect the client with server using:
$ ssh -L 3307:localhost:3306 user#Host -N -f
It is working. But now I am thinking whether it is possible to start the ssh tunneling from the server side. It means run a ssh command on server machine so that I get a more secure connection

How to ping to my local machine from AWS EC2 instance?

I have started an ubuntu instance on AWS EC2
e.g. [ec2-user#ip-XXX-XX-XX-XX ~]$
Inside this instance, I am running a socket program for sending the data to my local system.
The program is running properly, but not able to connect to my local IP.
I am trying to ping my local system also from AWS ec2 user, but it is also not working.But I am able to ping google(8.8.8.8).
e.g. [ec2-user#ip-xxx-xx-xx-xx ~]$ ping xxx.xxx.xx.xx(my local IP)
I have set all security groups(inbound), like All Trafic,All TCP and so on.
Sorry for bad English.
Thank You
Your computer (PC) cannot be pinged from an AWS hosted machine
This is probably because the VM on your computer is using NAT outbound to talk to the LAN, which goes to an Internet router, which sends the packets to AWS
The reverse route (inbound to your PC) does not exist so starting a ping echo request from a AWS machine will not work
It is possible to get around this by opening a pass through on your router but generally this is not a great idea
However if you want to make a socket connection securely there is a way
First, start a ssh session with remote port forwarding. In the Linux ssh client this is using the -R option.
For example, if your local system is running a listening service on port 80 and your remote system has the address of 54.10.10.10 then
ssh -R 8080:localhost:80 ec2-user#54.10.10.10
Will establish a circuit such that connections to the "localhost" on the remote ec2 server on port 8080 are connected to the "localhost" on port 80 of your local machine
If you are not using a ssh cli program, most ssh clients have a facility of this sort.
Note that it is necessary to keep the ssh session open to be able to use the connections

Error on Virtual machine Bluemix connection

I do not get connection with this VM: ssh ibmcloud#129.41.147.70
ssh: connect to host 129.41.147.70 port 22: Network is unreachable
Could it be that firewall rules now prevent me to connect to
129.41.147.70?
I believe you need to specify the ssh key, like:
ssh -i your_public_key ibmcloud#129.41.147.70
Also, check if the VM is runnning in the Bluemix UI and if you can ping the server from your machine.
Actually if you can ping it, it is likely a firewall issue with the error you are seeing.

PostgreSQL SSH port forwarding via Windows/PuTTY

I have PostgreSQL 9.4 running on a Linux VPS, and I need to be able to connect to it over SSH from both Linux and Windows clients. (I will later need to connect to multiple servers, and so that all clients use the same port numbers, I'm forwarding to port 5551 for the first server, then I will use 5552, 5553, etc.)
From a Linux client I just run ssh -fNg -L 5551:localhost:5432 user#remote1.com and connect to localhost:5551 with PGAdmin3 or any other client app. Works great.
On Windows, I'm using PuTTY and Pageant. I got the connection to user#remote1.com via terminal working, then I went to the SSH Tunnels and added L5432 localhost:5551. Terminal connection still works, but when I try to connect with PGAdmin3 to localhost:5551 I get an error:
could not connect to server: Connection refused (0x0000274AD/10061) Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5551?
I resolved it. Like many things, this is obvious in hindsight. I had things backward in the SSH Tunnels setup in PuTTY. It needs to be L5551 remote1.com:5432

Copy file or directory from remote server

I try to copy file from remote server to my local machin but it gives following error
ssh: connect to host 103.241.144.137 port 22: Connection refused.
command : scp root#111.111.111:/home/msecondo/public_html/jsp/afterLogin/sachin/PHR/ /localpth/.
"Connection refused" means that there was no process accepting connections at the IP address and port that your client tried to connect to. In this case, it probably means that there is no SSH server running at 103.241.144.137 port 22. Alternately, if the SSH server is running, it may not be listening on the IP address or port that you tried to connect to.
StackOverflow isn't the right site for troubleshooting SSH server configuration. If you have administrator privileges on the remote server, then you should look into how the SSH server is configured and whether it's running. If you're not an administrator on the remote server, you should report this to the administrators so that it can be investigated.