LoginSignup
0
0

More than 1 year has passed since last update.

リモート先で立ち上げたdockerへ直接ssh接続するときのconfigの書き方

Last updated at Posted at 2022-10-28

EC2上のdockerコンテナを立ち上げたときに、dockerコンテナへsshしたいことがありました。
その時、ssh configにどのような記載をすればいいのだろう・・・?となったので、
書き方を共有します。
EC2へssh接続するときの参考にもなると思います。

操作端末はwindows、sshに使うクライアントはgit for windowsのものを使用します。

Host EC2
    HostName {EC2_ipadress}
    User ubuntu
    IdentityFile C:\Users\*****\.ssh\EC2_ssh_key.pem
    CheckHostIP no
    ControlMaster auto
    ControlPersist  600
    IdentitiesOnly yes
    ForwardAgent yes
    RemoteForward 22 127.0.0.1:22
    ServerAliveInterval 60
    ServerAliveCountMax 3
Host EC2_docker
    HostName 127.0.0.1
    User root
    Port {docker_port}
    IdentityFile C:\Users\****\.ssh\docker.pem
    ProxyCommand C:\Program Files\Git\usr\bin\ssh.exe -W %h:%p EC2
0
0
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
0
0