トップ 一覧 検索 ヘルプ RSS ログイン

tips-sshの変更点

  • 追加された行はこのように表示されます。
  • 削除された行はこのように表示されます。
SSH のTips

以下のコマンドを実行した際に
 ssh -L 8080:192.168.1.110:8080 \
     -L 8021:192.168.1.110:8021 foo@bar.host.name
 
 # channel 7: open failed: administratively prohibited: open failed
 と言うのは
 接続先のホストからセッションが張れない場合

NEXT1
  (ログイン先の fobar.host.name に pot:10022 で開く(192.168.110.10:10022 にトンネルをはる))
 % ssh foo@bar.host.name -R 10022:192.168.110.10:10122
 ログイン先で 10022 に接続する
NEXT2
  (ログイン元の10022 でポートを開き fobar.host.name に接続して 192.168.110.10:10022 で開く(192.168.110.10:10022 にトンネルをはる))
 % ssh foo@bar.host.name -L 10022:192.168.110.10:10122
 ログイン元で 10022 に接続する

! PROXY 設定
 SOCKS::
 $ssh hoge00@192.168.250.10 -o ProxyCommand="nc -X 4 -x 127.0.0.1:18080 %h %p" -o HostKeyAlgorithms=+ssh-dss  -i ~/.ssh/hoge00.key
 
 SQUID::
 $ssh foge00@192.168.250.10 -o ProxyCommand="nc -X connect -x 127.0.0.1:18080 %h %p" -o HostKeyAlgorithms=+ssh-dss  -i ~/.ssh/foge00.key


! Unable to negotiate with LOGIN.HOST.NAME port 22: no matching host key type found. Their offer: ssh-dss
 Legacyなアルゴリズムを使っているので指定して接続する
 ssh -oHostKeyAlgorithms=+ssh-dss -l username LOGIN.HOST.NAME


!iptable などを ssh でログインした時に再起動する方法

  nohup sh ./iptables-reset.sh > reset_log &

! PassWord なしの
 ユーザ以下で
 > ssh-keygen -t rsa
 Generating public/private rsa key pair.
 Enter file in which to save the key (/home/foge00/.ssh/id_rsa): 
 Created directory '/home/foge00/.ssh'.
 Enter passphrase (empty for no passphrase): 
 Enter same passphrase again: 
 Your identification has been saved in /home/foge00/.ssh/id_rsa.
 Your public key has been saved in /home/foge00/.ssh/id_rsa.pub.
 The key fingerprint is:
 XX::XX foge00@ProxyTest.hoge
 The key's randomart image is:
 +--[ RSA 2048]----+
 |                 |
 |                 |
 |                o|
 |       + . .   oo|
 |        S o   .o.|
 |       * . o o..o|
 |        o.  o .o+|
 |        E o .. o.|
 |         ..+. .  |
 +-----------------+
 > 

 ターゲットホストで上記のコマンドを実行する 
 id_rsa.pub と id_rsa の2つのファイルが $HOME/.ssh に作成される
 
 id_rsa.pub を ターゲット側(ログイン先)の $HOME/.ssh に
 authorized_keys (ないに)( 400byte くらい) としてCOPYする
 ( 既にある場合には追加する )
 
 id_rsa を hostname.key として ホスト側 ( ログイン元 ) にコピーして
 ssh foo@bar.host -i hostname.key 
 として使う


! GUI アプリケーションを使う
   設定ファイル: /etc/ssh/sshd_config
 ## X11Forwarding yes
 #   ForwardX11 no
   ForwardX11 yes
 を設定する
 # service sshd restart

! root 
 # vi /etc/ssh/sshd_config
 
 # LoginGraceTime 2m
 # PermitRootLogin yes → PermitRootLogin no に変更
 # StrictModes yes

! Next
 @    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
 ssh-keygen -R 192.168.12.199 -f /home/hoge/.ssh/known_hosts