SSHでVirtual box上のDebianに接続(後編)
前回の作業で鍵の作成まで終わりました。ここから鍵をサーバーに登録して接続しなくてはいけないのですが、ここで詰まり何時間もGoogle検索することに・・・。
1 Virtual boxの設定の変更
Linuxを1度シャットダウンし、VirtualBox全体の設定を変えます。[VirtualBox]->[環境設定]をクリック。表示されたダイアログの[ネットワーク]をクリックします。
ホストオンリーネットワークで右の+マークをクリックしてokを押します
先程は全体のVirtual Boxの設定を変えたのですが今回は個別の設定をいじります。[設定]->[ネットワーク]->[アダプター2]をクリック。「ネットワークアダプタを有効化」にチェックを入れ、「割り当て」を「ホストオンリーアダプタ」にします。「名前」はデフォルトのもので大丈夫です。
2 ネットワークの設定
Debianの/etc/network/interfaces を編集して、さっきのホストオンリーアダプタの設定を追加します。
# This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # The primary network interface allow-hotplug eth0 auto eth0 iface eth0 inet dhcp allow-hotplug eth1 auto eth1 iface eth1 inet static address 192.168.56.101 gateway 192.168.56.1 netmask 255.255.255.0
これによってeh1が新しく追加される。
3 SSHで接続
今度はMacのターミナルからscpコマンドでclient_rsa.pubを送ります。
$ scp ~/.ssh/client_rsa.pub ユーザー名@192.168.56.101:~
sshで接続
$ ssh ユーザー名@192.168.56.101
参考
http://ginpen.com/2011/02/24/ssh-for-linux-on-virtualbox/
http://www.tooyama.org/ssh-key.html
http://www.nekotricolor.com/blog/2013/03/15/904/