ssh公開鍵の置き方

本日ssh公開鍵の置き方を教えていただきました!!

いつも他の人に鍵を置いてもらう事ばかりでしたが、これからは自分で誰かの鍵を置いてあげることができるようになりました!!

忘れないように書いておきます!!

 

手順

sshでログイン
$ ssh hoge-hayashi@hoge-app1  -p 50022

Last login: Wed May 29 14:39:18 2019 from nttkyo898237.tkyo.nt.ngn.ppp.infoweb.ne.jp



       __|  __|_  )

       _|  (     /   Amazon Linux AMI

      ___|___|___|



https://aws.amazon.com/amazon-linux-ami/2015.09-release-notes/

117 package(s) needed for security, out of 243 available

Run "sudo yum update" to apply all updates.

Amazon Linux version 2018.03 is available.

 

 

rootユーザーになる
[hoge-hayashi@app1 ~]$ sudo -i



We trust you have received the usual lecture from the local System

Administrator. It usually boils down to these three things:



    #1) Respect the privacy of others.

    #2) Think before you type.

    #3) With great power comes great responsibility.



[sudo] password for hoge-hayashi: パスワードうつ

 

rootユーザーになると最初にいるディレクトリは/root です。

[root@app1 ~]# pwd

/root

 

 

/home/deployへ移動
[root@app1 ~]# cd /home/deploy

 

ls -l -aすると色々みれます。

[root@app1 deploy]# ls -l -a

合計 84

drwx------  7 deploy  10007  4096  6月  7 12:05 .
drwxr-xr-x 13 root   root    4096  528 15:34 ..
drwxr-xr-x  3 deploy  10007  4096  7月  6  2016 .ansible
-rw-------  1 deploy  10007 22517  617 21:17 .bash_history
-rw-r--r--  1 deploy  10007    18  9月  3  2015 .bash_logout
-rw-r--r--  1 deploy  10007   193  9月  3  2015 .bash_profile
-rw-r--r--  1 deploy  10007   124  9月  3  2015 .bashrc
drwxrwxr-x  3 deploy deploy  4096  3月  2  2017 .bundle
drwxrwxr-x  4 deploy  10007  4096 1221  2015 .gem
-rw-------  1 deploy  10007  2256  6月  7 11:27 .lesshst
-rw-------  1 deploy deploy   356  3月  2  2017 .mysql_history
drwxrw----  3 deploy  10007  4096  113  2016 .pki
drwx------  2 deploy  10007  4096  528 16:33 .ssh
-rw-------  1 deploy deploy 10763  6月  7 12:05 .viminfo

 

 

 

.ssh/authorized_keysファイルを開く

.ssh/authorized_keysの中にssh公開鍵が置いてあるのでviewコマンドやvim等で開くとみれます。

[root@app1 deploy]# view .ssh/authorized_keys

 

ずらりと公開鍵が置いてあるのがみれます。

gyazo.com

 

 

Linuxの知識薄すぎるので勉強がんばってゆきます!