LoginSignup
4
4

More than 5 years have passed since last update.

vagrantから外環境へ繋ぐための設定

Posted at

Vagrantファイルに下記を追記

# ローカル環境から外環境へ繋ぐためのトンネル設定
  config.vm.provision "shell", inline: <<-SHELL
    sudo cp -p /vagrant/PEMファイル /home/vagrant/.ssh/
    sudo chmod 600 /home/vagrant/.ssh/PEMファイル
    sudo ssh -f -N -C -oStrictHostKeyChecking=no -L 繋げるためのローカルのポート:外部サーバ:外部サーバでの受け口のポート 外部サーバでのユーザ名@外部サーバ -i /vagrant/PEMファイル
    # ↑のプロセスを切る方法
    # ps aux | grep ssh ⇒ kill -9 XXXXXX
  SHELL
4
4
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
4
4