0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

MacでVirtualBoxを使うときにコピペができるようにする手順

Last updated at Posted at 2024-12-14

VirtualBoxにインストールしたUbuntuへコピペがしたい

 VirtualBoxにUbuntuをインストールし、Dockerを使えるように設定を行おうとした。dockerだけなら手作業でも気合いでできそうなコード量だが、docker-composeはさすがに厳しい(https:/~とか面倒すぎる)。ネットの記事でコピペできる方法を探したが、GUIを使った場合の説明がほとんどでCUIでやっているケースには当てはまらない。
 ということで、MacでVirtualBoxの仮想環境でコマンドがコピー&ペーストできるようになるまでをまとめて記録しておく。

環境

MacOS Sequoia 15.1.1
Oracle VirtualBox バージョン 7.1.2
-オペレーティングシステム:Ubuntu(ARM64bit)

Step1 IPアドレスを確認する

VirtualBoxで以下のコマンドを入力

$ ip a

enp0s8:という部分にIPアドレスが書かれているのでメモしておく。
(192.168.~となっている人が多い?)
enp0s8:の表示が出ていない場合は、Oracle VirtualBox マネージャーから「設定」を開き、「ネットワーク」のアダプターを「ブリッジアダプター」にしておく

Step2 SSHサーバをインストールする

VirtualBoxで以下のコマンドを一行ずつ入力

$ sudo apt update
$ sudo apt install openssh-server
$ sudo ufw enable
$ sudo ufw allow 22
$ sudo ufw reload

SSHサーバが起動していることを確認

$ sudo systemctl status ssh

以下のようなものが出ていればOK

● ssh.service - OpenBSD Secure Shell server
    Loaded: loaded (/usr/lib/systemd/system/ssh.service; disabled; preset: ena>
    Active: active (running) since Sat 2024-12-14 13:26:37 UTC; 17min ago
TriggeredBy: ● ssh.socket
      Docs: man:sshd(8)
            man:sshd_config(5)
   Process: 1679 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
  Main PID: 1680 (sshd)
     Tasks: 1 (limit: 2212)
    Memory: 1.9M (peak: 2.9M)
       CPU: 69ms
    CGroup: /system.slice/ssh.service
            └─1680 "sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups"

Step3 Macのターミナルからssh接続する

ターミナルを開き、メニューバーから「シェル」>「新規リモート接続」を選択する。そして、サービスは「ssh」にして、サーバは下の「+」ボタンをクリック。
screenshot2024-12-1422_59_04.png
すると、IPアドレスを入力するように求められるので、先ほどメモしたIPアドレスを入力する。
screenshot2024-12-1422.59.19.png
最後にUbuntuにログインする際のユーザ名を入力して「接続」ボタンをクリックする。
screenshot2024-12-1423_09_20.png
すると、ターミナルのウィンドウが開き、VirtualBoxで起動をした場合と同じようにパスワードを求められる。

screenshot2024-12-1423.09.35.png
あとは、パスワードを入力すればターミナル上でUbuntuが操作でき、コピペも可能になる。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?