Multipassで作成した仮想マシンにsshで接続する
ssh-keygenでキーの生成
sshで接続するためにssh keyの生成を行います。
ssh-keygen -t ed25519 -C "your_email@example.com"
Multipass VMのIPアドレスを確認する
% multipass list
Name State IPv4 Image
real-bream Stopped -- Ubuntu 22.04 LTS
test Running 192.168.64.15 Ubuntu 22.04 LTS
ホスト側の~/.ssh/configに接続先情報を追記する
Host <識別名>
Hostname <IPアドレス>
Post 22
identityFile ~/.ssh/<秘密鍵>
User ubuntu
公開暗号キーをコピーする
cat ~/.ssh/<公開鍵.pub>
pbcopy < ~/.ssh/<公開鍵.pub>
Multipass VMの~/.ssh/authorized_keysに追記する
multipass shell <host>
vim ~/.ssh/authorized_key
cat ~/.ssh/authorized_key
% multipass shell test
Welcome to Ubuntu 22.04.1 LTS (GNU/Linux 5.15.0-52-generic aarch64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
System information as of Sun Nov 6 00:02:28 JST 2022
System load: 0.16552734375
Usage of /: 28.8% of 19.21GB
Memory usage: 28%
Swap usage: 0%
Processes: 107
Users logged in: 0
IPv4 address for enp0s1: 192.168.64.15
IPv6 address for enp0s1: fdd3:cc13:ce8d:a4ec:5054:ff:fe6a:ad85
* Strictly confined Kubernetes makes edge and IoT secure. Learn how MicroK8s
just raised the bar for easy, resilient and secure K8s cluster deployment.
https://ubuntu.com/engage/secure-kubernetes-at-the-edge
7 updates can be applied immediately.
7 of these updates are standard security updates.
To see these additional updates run: apt list --upgradable
Last login: Sat Nov 5 23:44:08 2022 from 192.168.64.1
ubuntu@test:~$ vim ~/.ssh/authorized_keys
ubuntu@test:~$ cat ~/.ssh/authorized_keys
ssh-rsa AAAAB...aGMFB ubuntu@localhost
ssh-ed25519 AAAAC...23qq3 <email address>
sshで接続してみます
% ssh test
Welcome to Ubuntu 22.04.1 LTS (GNU/Linux 5.15.0-52-generic aarch64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
System information as of Sun Nov 6 00:06:28 JST 2022
System load: 0.01123046875
Usage of /: 28.8% of 19.21GB
Memory usage: 27%
Swap usage: 0%
Processes: 106
Users logged in: 0
IPv4 address for enp0s1: 192.168.64.15
IPv6 address for enp0s1: fdd3:cc13:ce8d:a4ec:5054:ff:fe6a:ad85
* Strictly confined Kubernetes makes edge and IoT secure. Learn how MicroK8s
just raised the bar for easy, resilient and secure K8s cluster deployment.
https://ubuntu.com/engage/secure-kubernetes-at-the-edge
7 updates can be applied immediately.
7 of these updates are standard security updates.
To see these additional updates run: apt list --upgradable
Last login: Sun Nov 6 00:02:29 2022 from 192.168.64.1
ubuntu@test:~$
VSCodeでMultipass VMへ接続する
Visual Studio Codeで同様にssh接続をためします。
Extention Remote - SSHのインストール
VSCodeの機能拡張からRemote - SSHを検索してインストールをします。