39
29

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 5 years have passed since last update.

vagrantの仮想マシンからscpでファイルをローカルに転送する

39
Last updated at Posted at 2016-05-25

1.OpenSSHの設定を行う

VagrantfileがあるディレクトリでOpenSSHの設定を行います

Vagrantfileのあるディレクトリ
$vagrant ssh-config

このコマンドで取得できるファイルをssh.configに書き込みます

Vagrantfileのあるディレクトリ
$vagrant ssh-config > ssh.config

2.scpコマンドでファイルをローカルに転送させる

Vagrantfileのあるディレクトリ
$scp -F ssh.config vagrant@default:/hoge.text ./

scp -F ssh.config [vagrant上のファイル] [移動先]

これでいま作業しているディレクトリにhoge.textがあるはずなので
それをしかるべきフォルダへ移動させて下さい!

vagrantでrsync-autoなどしている方でしたら使えると思います!

3.参考

vagrantのrsyncについて
http://www.1x1.jp/blog/2014/03/vagrant-rsync-synced-folder.html

OpenSSHについて
http://www.unixuser.org/~euske/doc/openssh/book/chap1.html

39
29
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
39
29

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?