Vagrant上のCentOSへは、デフォルトではvagrantユーザの秘密鍵をつかった認証でログインする。
自分はNotepad++を使ってリモートのファイル編集をしたかったのだが、vagrantユーザだと一部のファイルを編集できなかったので、rootでログインする方法から調べた。
環境
ホストマシン: Windows10
仮想化ソフト: Oracle VirtualBox 5.1.12
Vagrant: Vagrant1.9.1
CentOS box: https://atlas.hashicorp.com/centos6/
(vagrant box add centos/6でダウンロードしたもの,CentOS6.8でした)
テキストエディタ: Notepad++ 6.7.4
CentOSでのルートログイン許可
ネットで調べると、以下をvagrantfileに記載すればよいとあったので実行。
For SSH login as root
config.ssh.username = 'root'
config.ssh.password = 'vagrant'
config.ssh.insert_key = 'true'
これで起動すると、
2017/01/15 21:15:48|C:\Vagrant\CentOS6-1>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'centos/6' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 5000 (guest) => 5000 (host) (adapter 1)
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: root
default: SSH auth method: password
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
となり、失敗し続ける。いろいろ調べた結果、box上で、/etc/ssh/sshd_configの以下を修正
PermitRootLogin yes
PasswordAuthentication yes
修正後、一応sshdを再起動
service sshd restart
これでrootで直接sshログイン可能になった。
Notepad++の設定
Notepad++インストール時に、NppFTPプラグインを入れるかどうか聞かれるので、インストールしておく。
すると、メニューのプラグインから、NppFTP用のウィンドウを表示できるようになるので、そこから設定を行う。
以上。これまではローカルで編集→Boxにコピーとしていたのでかなりラク。