情弱エンジニアのなかのblog

一人前のエンジニアになる為のブログです

vagrant内のプロジェクトをatomで開く

vagrantを使ってアプリ開発をしていましてatomでコードを書いているのですが いちいちFTPを開いてファイルを選択するのが面倒なので、 サイドにプロジェクトのツリービューを出す方法を調べました。

まずパッケージのインストールが必要になります。 atomで「remote-ftp」を検索してインストールしてください。

Packages→「Remote-FTP」というのが追加されているので「Create SFTP config file」を選択してください .ftpconfigというファイルが生成されるので設定をしていきます。

設定内容に関しましてはwindows powershellを開いて「vagrant ssh-config」で 下記のように接続に必要な情報が表示されます。

PS C:\Users\user\MyVagrant\MyCentOS> vagrant ssh-config
Host default
  HostName 127.0.0.1
  User vagrant
  Port 2222
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile C:/Users/user/MyVagrant/MyCentOS/.vagrant/machines/default/virtualbox/private_key
  IdentitiesOnly yes
  LogLevel FATAL

.ftpconfigは以下のようになっているのでssh-configの内容を参考にして記載していきます。

{
    "protocol": "sftp",
    "host": "127.0.0.1",
    "port": 2222,
    "user": "vagrant",
    "pass": "パスワード",
    "promptForPass": false,
    "remote": "/home/vagrant",
    "local": "",
    "agent": "",
    "privatekey": "/Users/user/MyVagrant/MyCentOS/.vagrant/machines/default/virtualbox/private_key",
    "passphrase": "",
    "hosthash": "",
    "ignorehost": true,
    "connTimeout": 10000,
    "keepalive": 10000,
    "keyboardInteractive": false,
    "remoteCommand": "",
    "remoteShell": "",
    "watch": [],
    "watchTimeout": 500
}

Packages→「remote-ftp」から「Toggle」を選択するとサイドバーが表示されます。 「Connect」を選択しますとサイドバーにディレクトリが表示されるので完了になります。