LoginSignup
1
0

More than 3 years have passed since last update.

SSH接続方法まとめ

Posted at

概要

ちょくちょく聞かれる内容を記事として残しておきます

鍵の生成

$ ssh-keygen -t rsa -b 4096 -f ~/.ssh/key-name -C "user-name@host-name"

コメントを削除したい場合は-C ""とすればよい

SSH接続

基本

$ ssh user-name@host-name 

よく使うオプション

  • -i 秘密鍵
  • -p ポート番号

configファイルを利用したSSH接続

configファイルを使う事で入力を簡略化する事が可能

configファイルの作成と権限の調整

$ touch ~/.ssh/config
$ chmod 600 ~/.ssh/config

設定例

Host ec2_test
  HostName xxx.xxx.xxx.xxx
  port 22
  User ec2-user
  IdentityFile ~/.ssh/aws-key

警告メッセージを出したくない場合は下記の設定を加えておくとよい

Host *
  StrictHostKeyChecking no
  UserKnownHostsFile=/dev/null

接続コマンド

configのHostで指定した値を使う事でコマンドの省略が可能

$ ssh ec2_test
1
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
1
0