LoginSignup
0
0

More than 3 years have passed since last update.

ssh接続

Posted at

windowsでも使える+便利なのでメモがてら

オーソドックス

まずはどこにファイルを作るか
<my user>/.sshに作るとよい。
その下にconfigファイルを作成して下記な感じで設定

config
Host hoge
  HostName abc #ホスト名とかIPアドレス
  User hoge
  IdentityFile ~/.ssh/hoge/id_rsa

みたいな感じ。
IdentityFileはもらった鍵を設定フォルダ管理方法は
個人個人に任せる感じで

あとは

ssh hoge

で入れるはず

踏み台経由

A「mainサーバーに入る際はfugaサーバーを経由してね」
僕「ssh2回も打つのめんどい」

なので踏み台経由で一発でログインできる方法

config
# 踏み台
Host bastion
  HostName fuga
  User fuga
  IdentityFile ~/.ssh/fuga/id_rsa

Host main
  HostName main
  user main
  IdentityFile ~/.ssh/main/id_rsa
  ProxyCommand ssh bastion -W %h:%p

これで

ssh main

で踏み台経由でログインできます。
簡単

サーバー間ファイル転送

A「mainサーバーのファイルを持ってきて。ちゃんとfugaサーバー経由してよろしく」
僕「scp2回も打つん?」

めんどいので前ページで使った設定を駆使してやります

scp main:<target path> <local path>

これでいける

A「君早いねこれからもこの作業よろしくね」
僕「スケジューラで登録して処理させろ」

以上

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