3
4

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.

SSHリモートサーバーのIPを通して、ローカルマシンのブラウザからウェブサイトにアクセスする

Last updated at Posted at 2016-08-24

SSHでアクセスしているリモートサーバーのIPを使って、ブラウザでウェブにアクセスする方法です。

ユースケース

特定のIPにアクセスを制限しているウェブサイトに、アクセスが許可されていないIPを持つローカルマシンから、アクセス許可されているIPを持つサーバーにSSHすることで、アクセスする.

方法

OpenSSH dynamic port forwardingを使う. 以下のコマンドを叩く. 変数は%{}で書いた.

ssh %{portとかkeyの情報} -D 1080 %{username}@%{ipaddress}

そして、ブラウザクライアントのSOCKS proxyを 127.0.0.1, port 1080 にセットする.

SSH/OpenSSH/PortForwarding: Dynamic Port Forwardingに詳細が書いてある.

これやんなきゃいけなかった。

You can also set Firefox to use the DNS through that proxy, so even your DNS lookups are secure:

Type in about:config in the Firefox address bar
Find the key called "network.proxy.socks_remote_dns" and set it to true

ssh configとの併用

configにhost-name-1というhostに関するconfigを書いてる場合は、以下のようにもアクセスできる. (要はこれやればいい。portとかkeyとかはデフォルトでいいので何もいれなくていい。)

ssh -D 1080 host-name-1

IPの変更がうまく行っていることの確認

自分のIPアドレスを確認できるサービス(これとか)で確認するといい.

参考

3
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
3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?