1
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?

仮想マシン上にコピペしたいが為にVirtualBoxでSSH接続の設定

Posted at

初期設定では、仮想マシン上にコピペ不可

VirtualBoxで仮想マシンを作ってLinuxを触り始めると、
「ホストOS ↔ ゲストOS間でコピペできない」 という壁にぶつかります。

Guest Additionsを入れれば解決するのですが、

  • パッケージのインストールが必要
  • そのインストールコマンド自体を手で打つのが面倒

という本末転倒な状況に。

💡 発想の転換

「コピペできないなら、SSHで直接つなげばいいじゃない

つまり:

  1. ホストOS(例:Windows)で調べたコマンドをコピー
  2. ターミナルからSSHで仮想マシンへ接続
  3. そのまま貼り付けて実行

これなら Guest Additions を頑張って入れる前でも快適に操作できます。

🔌 接続方法は2通り

1. NAT + ポートフォワード

  • VirtualBoxのデフォルト設定
  • 例)ホストOSの2222番ポート → ゲストOSの22番ポート(SSH)に転送

接続コマンド例(Windows Terminalから):

powershell
ssh -p 2222 user@127.0.0.1

2. ブリッジ接続

  • ゲストがLAN内で「普通のPC」として振る舞うモード
  • ホストと同じネットワークのIPが割り振られる
    接続コマンド例:
powershell
ssh user@192.168.100.xxx

まとめ

  • NATでもブリッジ接続でもOK
  • 実務で生かせそうな手法
  • さらに派生して応用が利かせそう
1
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
1
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?