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?

More than 3 years have passed since last update.

Vagrant+VirtualBox+Ubuntu18にSSH接続

Posted at

UbuntuにSSHでパスワード アクセスするまでの流れ

備忘録につき手順検証していないので、あしからず。

環境、バージョン

  • 作業OS:Windows10 Pro 64bit
  • Vagrant Ver 2.0.1 (結構古い)
  • VirutalBox 5.0 (これもちょっと古い)
  • Ubuntu18.04.4 LTS

前提

VagrantとVirtualBoxはインストールしておく

Ubuntuのイメージをインストール

以下Vagrantファイルを作成

Vagrant.configure("2") do |config|
    config.vm.box = "ubuntu/bionic64"
end

コマンドラインで以下を実行

# vagrant init bento/ubuntu-18.04
# vagrant up

VirtualBoxのネットワーク設定を編集

ネットワーク>アダプター1 
割り当て:NAT
>高度
 ポートフォワーディング
 プロトコル:TCP
 ホストIP:
ホストポート:2222 (接続する際に使用するポート:2222じゃなくても可)
ゲストIP:UbuntuのIPアドレスを指定(1ホストしかUPしないなら空でもOK)
 ゲストポート:22
 

SSHでアクセス

Vagrantが公開しているUbuntuイメージには、Vagrantユーザーが作成されていて
VirtualBoxの表示で画面を表示すれば、vangrantユーザーでログインできる。
ただ、この状態で、RLoginやTeraTermでsshアクセスしようとしても
Keyファイルを指定しないとアクセスできない。

sshd

セキュリティ的には、Keyファイルでアクセスしたほうが安全だが、ローカル環境にいちいちKeyファイルで
ログインするのも面倒なので、パスワードでログインできるようにsshd.configを編集する。

vagrant@ubuntu-bionic:~$sudo vim /etc/ssh/sshd_config

ファイル内の以下をyesに変更

PasswordAuthentication yes

一応sshdを再起動

vagrant@ubuntu-bionic:~$sudo systemctl restart sshd

これでRLoginやTeraTermでパスワードログインできるようになる。

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?