Azure VM migration - access denied - azure

I followed this guide: Copying a virtual machine from one Windows Azure subscription to another with PowerShell to move a Virtual Machine between two subscriptions.
It worked fine, I could log in to the machine (by SSH).
Then (in the destination subscription), I changed the VM size (from A2 to A0), and now I am getting the error:
Access is denied
while logging by SSH. It is a dev machine, I am the only user (none changed my password).
I tried to put the size back to A2 without success.
Do you have any hints?

Assuming that you have installed the Linux Agent, try resetting your credentials using preview portal:
Navigate to Azure Preview Portal >> Browse >> Virtual machines >> Select your VM >> All settings >> Password reset
You can also reset SSH config clicking "Reset Remote Access" in VM dashboard.

Related

Unable to mount file on windows from Azure

I made a file on Azure using "File Service" and then tried to mount it using "connect". It has given me the username: localhost\xyz.
Two questions:
why username starting from "localhost" and not with "Azure"?
why I am unable to mount as windows security not giving any error, instead keep on turning back to credentials page?
p.s. TCP port 445 working properly..
Here are a few workarounds that worked for us.
WAY-1
You can directly go to your PowerShell of your machine and paste the script that you have provided in your storage account
WAY-2
You can click on More options and select for different account and then use the storage account name prepended with AZURE\ as the username and a storage account key as the password.
WAY-3
You can create a file share directly by unchecking the connect using different credentials.
OUTPUT:
For all the above ways here is the screenshot of fileshares that got mounted.
REFERENCES:
Mount SMB Azure file share on Windows

Windows Machine File Copy - DevOps task and IP address

I am building a Release Pipeline on Azure DevOps. Part of my release is to copy a bunch of files to the Azure VM. As far as I understand, the target machine needs to have PowerShell 5986 port open.
I have a VM with port 5986 open (I verified that by invoking remotely some commands on this VM with "PowerShell on Target Machines" task).
I added "Windows Machine File Copy" task and filled fields:
- Source
- Machines
- Admin Login
- Password
- Destination Folder
In "Machines" field, I put IP of the target machine.
As a result of running the release, I'm getting an error:
Failed to Create PSDrive with Destination:
'\\11.11.11.11\C$\TargetDirectory',
ErrorMessage: 'The network path was not found' The network path was
not found
I also tried to put IP address with a port, in this form: 11.11.11.11:5986
Then, I got this error:
Cannot convert value "\23.97.151.221:5986" to type "System.Uri".
Error: "Invalid URI: The hostname could not be parsed."
Documentation (https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/windows-machine-file-copy?view=azure-devops) says that IP address with a port is allowed.
What's the issue here?
I was getting the exact same error while doing these:
Initially in my release pipeline, I had an agent job and I created a Windows machine file copy task under the job and filled in all details correctly. I set the Machines field with the public IP address of my target server (a Windows azure VM) and I always got this error you reported.
I tried to use the Azure file copy task instead but I was faced with another problem (error message: Unable to get FQDN for all resources in ResourceGroup: {resourceGroupName}) which I couldn't get to fix after a lot of efforts.
This is the solution that worked for me:
Instead of running an agent job, I ran a Deployment Group Job. With deployment groups, I didn't need an IP address to connect to my VM. Setting up a deployment group for your Azure VM is very simple and well explained here
I created a Windows Machine File Copy task under the Deployment Group job I added. I filled same details for the task except that instead of the IP address of the Windows VM, I entered the computer name in the Machines field and the file copy task ran successfully!
I hope this helps
The problem is because you can't use that task to copy files across Windows Domain boundary! That is to say, if you build on host A and want to copy files to host B, then A and B must be in the same Windows Domain, otherwise you'll get the error like
##[error]Failed to Create PSDrive with Destination: '\\your-server-name-or-ip\some\path', ErrorMessage: 'The network path was not found'
That is to say, if you're using a hosted agent, then you're not able to copy files with that task to any host you have, no matter it has a public IP or not, or a FQDN, because they are not in the same Windows Domain!
You have two options to work around it:
Use Azure File Copy task if your target is an Azure VM or Azure Storage
Use private hosted agent and make sure your target host and your private agent are in the same Windows Domain
Last but not least, the document should really make it clear! It wasted me a lot of time on solving the problem!
go to the destination folder, right-click the folder select properties,share option is there, click that one and share everyone option is there
The solution is to go to the target server and SHARE the directory where the files would be copied. In Windows, just go to Properties of the directory, Sharing tab, and Share it to the user which is used in the VSTS task.
The answer is pretty simple, the DevOps Tasks are actually running PowerShell on you VM and trying to create a PSDrive.
Try using the task mentioned in the screenshot below:

How to copy files & run commands on remote Azure Win VM?

From my local Windows command prompt, I can copy files to local Windows machines, and run commands on the local Windows machines with psexec. (For example, launching .bat files). I can also start/stop and query services on the Windows machines, for example with sc \machineIP query (servicename).
I am learning to be able to do the same thing with a stock Windows machine hosted in Azure.
Having created a stock Windows Server VM in Azure from the command line, what more must I do? Currently on the Azure VM, for testing, I have:
Turned off the Firewall
Disabled simple file sharing wizard
Shared C, with permissions for 'everyone'
Started 'remote registry' service
Added registry key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\LocalAccountTokenFilterPolicy with value of 1 (hex)
I am able to RDP to the machine without a problem, with the given public IP address, username, and password.
I note that I cannot access: \publicIP\c$
And psexec returns 'The network path was not found. Make sure the default admin$ share is enabled on (publicIP)' when running the command:
psexec.exe \\(publicIP) -u(username) -p (password) -i 1 cmd /c c:\runMe.bat
In the Azure portal, navigate into the resource group where your VM resides. Select the 'Network Security Group' profile used by your VM (eg, yourVMnameNSG) -> edit -> add inbound security rules.
eg:
Name: psexec
Source: any
Destination: any
Service: Custom (Any/135)
Action: allow
Repeat for required services

azure linux vm recovery - unable to remote login

forgot user name password for a linux (ubuntu) vm. tried to "Reset Remote Access" from the portal, but it is not helping - more than 30 minutes - it still shown in progress. Tried to do it via azure command line. Created a new user with password, but unable to login. SSH says access denied. Should I do any additional steps?
After creating new user you should also reset your SSH connection. You could refer to Reset Access and Manage Users and Check Disks with the Azure VMAccess Extension for Linux for detailed steps.

Azure - Redeploy existing windows VMs in Azure to connect to Virtual Network

I need to connect my existing VMs to new Virtual Network. Documentations says you have to redeploy them, but I could not find any source which says how to redeploy an existing VM.
Thanks,
Prasad
Create an image of your VM:
Select your VM
Hit Capture on the bottom bar. Give it a name and make sure it completes successfully
Navigate to Cloud Service >> Select the CS >> Delete >> Chose CS and it's deployments
Review the list of VMs and disks that are going to be deleted
Delete
Redeploy the VM from Image:
Click New >> Compute >> Virtual Machine >> From Gallery
On the right side >> Click My Images >> Select your captured image
Complete the wizard. Make sure to select the correct Virtual Network.
Pre-requisites:
Virtual Network is in the same location as the captured Image. Otherwise you will have to move the VHD to a storage located in the same data center as the new Virtual Network. Virtual Network will not show up on the list if this pre-requisite is not met.
If you intend to use the captured image to deploy several other VMs with the same content you will have to run sysprep (windows) or deprovision waagent (linux) before capturing. Otherwise you will have connectivity problems since all the vms will share the same unique Ids.
More Info:
How to Capture a Windows Virtual Machine to Use as a Template:
http://azure.microsoft.com/en-us/documentation/articles/virtual-machines-capture-image-windows-server/
How to Capture a Linux Virtual Machine to Use as a Template: http://azure.microsoft.com/en-us/documentation/articles/virtual-machines-linux-capture-image/

Resources