LoginSignup
0
0

More than 5 years have passed since last update.

Azure の IaaS サービス Virtual Machine で 鍵ファイルで ssh接続をしてみた

Posted at

AzureのIaaSサービスVirtual Machineでssh接続をしてみます。もちろん鍵ファイルを使います。

Azure CLI をインストール (2.0)

$ curl -L https://aka.ms/InstallAzureCli | bash

$ az -v
-bash: az: command not found

exec -l $SHELL
# これでパスがとおります

$ az -v
azure-cli (2.0.9)

ログイン

$ az login
To sign in, use a web browser to open the page https://aka.ms/devicelogin and enter the code ********* to authenticate.
# ********はコード。ブラウザからコード認証してログインします。成功するとブラウザに成功した旨が表示されます。その後ブラウザは閉じてよい (そういうメッセージ)。
# ブラウザでコード認証がおわるとCLIでもログインが完了し、jsonでステータスが返却されます(省略)

VM起動 (鍵付き、ubuntsu)

$ az group create --name myResourceGroupVM --location eastus
# 成功するとjsonでステータスが返却されます(省略)

$ az vm create --resource-group myResourceGroupVM --name myVM --image UbuntuLTS --generate-ssh-keys
SSH key files '****/.ssh/id_rsa' and '****/.ssh/id_rsa.pub' have been generated under ~/.ssh to allow SSH access to the VM. If using machines without permanent storage, back up your keys to a safe location.
# **** はmacへログインしているユーザのカレントディレクトリのパスです。

$ssh xx.xx.xx.xx
# xx.xx.xx.xx は起動したVMのグローバルIPです。ユーザ名は鍵ファイルを使うので不要。鍵ファイルは.ssh配下に存在しています

ログインできました

参考

https://docs.microsoft.com/ja-jp/cli/azure/install-azure-cli
https://docs.microsoft.com/en-us/azure/virtual-machines/linux/tutorial-manage-vm

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0