0
0

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.

秘密鍵の設定

Last updated at Posted at 2014-02-18

※超基本的な解説です※

sshのログの確認

なんかうまくいかない時はログを見る←超基本なので覚えるべし

# cat /var/log/secure

うまくいっている時の所有者とアクセス権

クライアント(User: hoge)側

$ ls -l ~/
drwx------.  2 hoge hoge    .ssh

$ ls -l ~/.ssh/
-rw-r--r-- 1 hoge hoge    config
-rw------- 1 hoge hoge    id_rsa
-rw-r--r-- 1 hoge hoge    known_hosts

サーバー(User: root)側

# ls -l
drwx------.  2 root root    .ssh

# ls -l ~/.ssh/
-rw------- 1 root root    authorized_keys
-rw-r--r-- 1 root root    known_hosts

鍵を複数使用したい場合

configの設定

192.168.x.yというサーバに対してrootでssh接続する個別の設定を作る

クライアント(User: hoge)側

$ vim ~/.ssh/config
config
Host 192.168.x.y 
    User            root
    IdentityFile    ~/.ssh/id_rsa-hoge

GitHubに鍵認証をする

凄く悩んだが簡単なことで解決した

秘密鍵: id_rsa-iganari
公開鍵: id_rsa-iganari.pub

秘密鍵のディレクトリ

~/.ssh/
-rw------- 1 root root id_rsa-iganari

公開鍵の登録

github -> 「Account Setting」->「SSH Keys」->「Add SSH key」
こちらにid_rsa-iganari.pubを登録する

configファイルに設定を追記

~/.ssh/config
+ HOST github.com
+ Hostname github.com
+ Identityfile             ~/.ssh/id_rsa-iganari

疎通確認

# ssh git@github.com
PTY allocation request failed on channel 0
Hi iganari! You've successfully authenticated, but GitHub does not provide shell access.
Connection to github.com closed.

これでsuceessfullyが出ればOK
出ない場合は下記で原因を探る

# ssh -vvv git@github.com

余談

  • 鍵の作り方
# cd ~/.ssh
# ssh-keygen -t rsa -C 'for iganari' -f ./iganari_rsa
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?