Cannot SSH To Microsoft Azure Linux VM (Ubuntu 17.10) - azure

I created a new Linux VM (Ubuntu 17.10), and trying to connect to SSH through CloudShell, but the command ssh suren#40.71.218.244 take forever and does not connect.
Port 22 is enabled.
I tried telnet from my local mac, and able to connect
telnet> open suren.eastus.cloudapp.azure.com 22
Trying 40.71.218.244...
Connected to suren.eastus.cloudapp.azure.com.
Escape character is '^]'.
SSH-2.0-OpenSSH_7.5p1 Ubuntu-10ubuntu0.1
Connection closed by foreign host. here
What am i missing?

After trying several things, a hard-refresh of browser and re-login to Azure Portal did the trick. After i login, i could see the option to "Request a cloudhsell and choose the type".
Adding screenshots, may help others.

From the above troubleshooting that has been done the only conclusion is that you are in a restricted network that block port 22.
You can use Port Query tools like tcping, psping or portqry to determine if port 22 (Default SSH Port) is listening. If you system can't communicated over port 22 then you might want to try when connected to a different network.

Related

(howto) run multiple ssh session through the one forwarded port (port redirection, tunnelling)

Sorry, if it is a trivial question: I use the port forwarding the port 22 on remote computer is redirected to port 2222 on my local computer. The tunnel is created with the following azure command:
az network bastion tunnel
I can start the first session with ssh
ssh seva#localhost -p 2222
and it works fine However, when I'm starting from another terminal window another ssh session with the same command
ssh seva#localhost -p 2222
the connection hangs and goes through only when the first connection is terminated I'm aware, that I can run multiple sessions with azure native client:
az network bastion ssh
But I need multiple sessions through the same port 'classical way' because it is obviously the way, the Visual Studio Code uses when I trying to connect with it the remote computer. One session is obviously for the terminal window and another one for data transfer.
Many thanks in advance.
=Seva
You can work around this limitation by enabling SSH multiplexing. The first session will setup a control connection, and any subsequent session will simply re-use this. This removes the need for a second connection which, weirdly enough, az network bastion does not seem to support.
To do this for all of your connections, add the following to your SSH client config (ie. ~/.ssh/config):
Host *
# Connection Multiplexing
ControlMaster auto
ControlPersist 600
ControlPath ~/.ssh/ctrl/%C
This should be all you need. If you want/need even more information though check out https://en.wikibooks.org/wiki/OpenSSH/Cookbook/Multiplexing.

"Unable to connect to remote host: Connection refused" error when trying to get two Azure VMs to communicate on different ports

I have two Azure VMs I set up to test a program I made. The program is to be run on both VMs, where synchronous operations are performed, requiring the VMs to communicate with eachother on different ports using TCP protocols. To access my Azure VMs, I SSH'd into them on port 22 using Putty on my local machine. The VMs are on the same subnet, and I am trying to get them to communicate with eachother via their public IP. I have set up both VMs inbound rules to accept messages from eachother on any port, using any protocol here is an example of this.
During the execution of my program, I encounter the following error "Unable to connect to remote host: Connection refused". After this, I did some investigating. First, I had both VMs ping eachother, which they successfully did. Then, on both VMs, I ran the command "telnet other.ip 22", where other.ip is the other VMs public IP. This seems to work, as seen in this image. When I run "telnet other.ip 6000", or any other port besides 22 for that matter, I get the same error of "Unable to connect to remote host: Connection refused". My rational is that if I can get the "telnet" command running on any port, that my program will likely work too.
I am not too sure what my issue could be at this point, and my internet searches have not helped me. I doubt there is an issue of a port being backlogged with communication requests given my current inbound rules. Also, I did try to change my inbound rules so that my VMs would receive messages on any port, using any protocol, from any source, which resulted in the same error (I then changed it back from 'any source' to only my other VMs public IP for security purposes).
According to your description, you may check two points:
If there is any firewall inside the VM that is blocking the connection from the external network with port 6000. For example, if you are using Ubuntu VM, you can refer to How to Set Up a Firewall with UFW on Ubuntu 18.04. Then disable the firewall with the command sudo ufw disable or add a firewall rule to verify this.
Run the command on Linux to see open ports. sudo netstat -tulpn | grep LISTEN. You should see port 6000 in the output. If not, it might mean that your program is not started well.
Let me know if you have any concerns.
Check your firewall rules. If your organization tent to use firewall then add port 6000 in inbound and outbound chain.
you can connect the remote host with port number only when it is in listening state.
sudo netstat -tulpn | grep LISTEN.

Access Azure VM from behind a NAT

So I am pretty new to all of this and currently learning about ssh and NAT.
So I have a VM setup on Azure and in order to connect to it I need to ssh into it. But the problem is I am unable to ssh into it because I am behind a NAT as I am currently studying in a University, hence getting "connection timed out" error all the time.
Also I have tried changing the default port(22) to 443 or 80 still same error which confirms I am behind a NAT.
So currently the only way to ssh is to use a VPN which works fine.
But after researching a bit I found that I can also use Reverse SSH Tunneling to achieve the same but couldn't figured out a way of how to do it. I know it is a bit riskier than using a VPN only but anyway just wanted to try.
So can anyone help me?
An outgoing SSH connection (your machine -> Azure VM) should not be affected if you are behind a NAT. NAT usually blocks incoming SSH access to your machine not out from it.
Also I have tried changing the default port(22) to 443 or 80 still the same error which confirms I am behind a NAT.
You changed the default port on which machine, you or the Azure VM? Changing the default port on your machine will not affect the outgoing SSH connection as it is only for incoming SSH connection to the SSH server on your machine (if you have one running locally).
Your best bet would be to actually look at the security groups of the Azure Virtual Network you VM is located in. Make sure it allows incoming SSH connection on port 22 to your VM.

I can't do connection with 3270 port

I have just installed a mainframe emulator and I have problems for running it. I think the problem is my 3270 TCP port. Reading a guide I found somebody say that you can do this:
telnet 127.0.0.1 3270
but when I try the answer is:
The connection to the host it can't be opened with port 3270 more or less
(I have windows in spanish) . Error on the connection.
Do you know how can I get connection with this direction and this port?
If I understand you correctly, you are trying to eliminate issues with your 3270 emulator configuration by attempting to telnet to the mainframe from the PC. Again, if my understanding is correct, then you need to use
telnet <ip or hostname of the mainframe>
In your example, you are using the local loopback address.
It is unlikely that you should be using port 3270. 3270 connections are typically configured on port 23, which is the default telnet port.
If the connection to the mainframe is successful, you can input any character string in the terminal and then press Enter.
An error such as this:
IKJ56710I INVALID USERID,xxxx
Will validate the fact that the port is open and that your emulator issues are down to something other than network problems (probably local configuration).

Windows Azure VPN public access

I created a VM in a VPN in Windows Azure. I added TCP endpoints for the particular machine which runs server 2012. But everytime I run a small program listening on TCP like the example in nodejs, any client simply refuses to connect. This happens even when I disable the firewall? I tried with linux (ubuntu) too. Can someone help me out and let me know what steps I am missing? I connected with:
server1.cloudapp.net:tcp_port
RDP and SSH work fine through TCP.
Here are a few things to check, which may provide more clue.
1) double check your endpoint, make sure the public port and private port are set correctly
2) rdp to the VM and do "netstat -an" to check if the port is indeed listening

Resources