Did you just change some network configuration on your Ubuntu virtual machine and now you’re not able to connect? Here’s how you can fix the ssh connection.
how to fix – ssh: connect to host x.x.x.x port 22: Connection timed out
I spinned up an Ubuntu (18.04.3 LTS, Bionic Beaver) virtual machine on Azure for an experiment. I was setting up apache2 server (for a web server) and in the process I made some changes in network configuration (I literally allowed IPv4 & IPv6 in the firewall, that’s all). While making those changes I got a clear message on the screen that the current network may be unstable but it continued to work flawlessly until the connection was closed. The very next day and I wasn’t able to connect to the Ubuntu VM using ssh on the same IP/Port. Though the web server was responding well at port 80.
What I tried first?
I had forgotten the warning message I received earlier, about the network instability, while making the changes in network configuration and now I had this. So, at first I jumped on to Azure Portal and I tried restarting the virtual machine, it didn’t work. I removed and re-added the allow port 22 under the Networking tab, it also didn’t work.
How to fix “ssh: connection to host X.X.X.X on port:22”?
So, I did some digging on the internet and I found two lines of script required to fix the connection. It’s a firewall issue, it gets updated while changing the network configuration. Thankfully, Azure Portal offers a console to run shell scripts from the browser itself.
You can find the “RunShellScript” option under Operations > Run Command on the virtual machine’s setting blade. I believe all the cloud providers offer similar connectivity for the VMs using which you can connect to the VM using ssh or RDP for recovery purposes. Please refer to the snapshot below
After I ran the two above lines, I tried to connect the virtual machine on the ssh and the connection was successful.
Edit: I later discovered that the commands in the browser console above can be run without “sudo“ prefix.
You can later verify the status of the firewall using “sudo ufw status” on the same window.
With ASP.NET Core 2.2 support added to Azure Web Apps – it’s a bit tricky to host multiple applications using Virtual Directories. If you just publish your web apps using Visual Studio on different virtual, directories – not more than one will work at the time I’m writing this.
You need to make certain changes in order to get this working.
Let’s try publishing some asp.net core apps on Azure Web App in under virtual directories and see how it looks like. I’ve set up a Web App on Azure for this purpose with below configuration on Azure portal:
I’ve created an Empty ASP.NET Core Web App (Ver 2.2). My plan is to change the text and publish apps separately on the root directory, and on two different virtual directories, making three apps in total on one azure web app.
My plan is to the default “Hello World” text to “App1 on Virtual Directory” and “App2 on Virtual Directory” subsequently and publish each on a different virtual directory. I will have to map two folders as virtual directories in order to get them working which can be done either before or after publishing the applications.
Downloading the Publish Profile helps quick publishing of azure web apps.
I added two virtual apps to the main apps at “/app1” and “/app2” virtual paths. So we have three apps now. Next I will publish the apps on the two virtual directories changing the default text.
I published the default application in Root Directory and it started saying “Hello World”, then I published the same app with changed text on App1 virtual directory but it failed to start with the following error, Same response for App2 on the next virtual directory. :
Cause: ASP.NET Core 2.2 and later has an In Process hosting model on IIS (set as default). In this model the app is hosted directly inside of an IIS Application pool (IISHttpServer Web Server), and it doesn’t proxy to an external dotnet.exe (instance running .NET Core native Kestrel Web Server).
Currently, only one app can run in one app pool (one azure app).
Host the apps as OutOfProcess model
In this case – all the apps are required to be hosted as OutOfProcess model. When you publish the application it generates the web.config file with all the set configuration.
Open the .csproj file and under Project > PropertyGroup > AspNetCoreHostingModel, change the value “InProcess” to “OutOfProcess”. Be careful with the casing here!
Note that all the apps has to be deployed in “OutOfProcess” model, otherwise no application (inside the given azure app) will run. This change has to be applied in all the projects you’re publishing under one azure app.
My apps start working as I change the hosting model from InProcess to OutOfProcess and publish them.
This way it enables us to host multiple applications inside a single Azure Web App.
Note, that OutOfProcess drastically reduces the throughput as it proxies the request between Kestrel Web Server running dotnet.exe and IIS Web Server.
Azure DevOps is a suite of services for Managing, collaborating, building and deploying code.
Azure DevOps Organizations are the starting point for Azure DevOps. You need a Microsoft account to sign-in. If you do not have one – sign up for a free account. Organizations are free up to 5 team members. An Organization can hold many projects.
Sign in and create your first Organization and add a project.
As you sign-in, it will create an Organization by default based on your login email. If you do not like it, feel free to change the Organization name by navigating to Organization Settings -> Overview. You can either keep the existing Url with the new organization name or change it along as well.
Once created, you will be navigated to your organization. The Url would be be like <your-organization-name>.visualstudio.com.
Here’s the first screen inside a newly created organization:
For the demo purposes – I’ve added a “HelloWorld-Project” project inside “helloworld-demo” Organization.
Note: the screens are subject to change hence by the time you read this blog, it is possible that the option has changed it’s place.
You can set project visibility to be public or private, version control (Git or TFVC) and the Work Item Process template (Agile/CMMI or SCRUM) to manage the tasks across the project board. I will go with Git version control and Agile work item process.
You can manage teams and add members to it under Project Settings at the bottom in the left.
Azure DevOps offers a group of services facilitating everything required to manage, build, and deploy a project from start to finish. Following services are available under the Azure DevOps suite:
Azure Boards, for work management
Azure Repos, for social collaboration
Azure pipelines, for building and releasing the project
Azure Test Plans, for Manual Testing and Load Testing
Azure Artifacts, for sharing different packages
Watch this space for detailed articles on the Azure DevOps services in my upcoming blogs.
Thanks for reading 🙂
Do you think this post can be improved? Please leave a comment.