본문 바로가기

Develop/Linux

Regist and use SSH KEY

Use ssh-rsa key to connect to the server.


Various useful things can be used.(But security should be careful)


]$ ssh-keygen -t rsa


Super easy ! Just press Enters..It make public key, private key.

Basic create path is ~/.ssh/id_rsa, ~/.ssh/id_rsa.pub

id_rsa is called private key.

id_rsa.pub is callged public key.


Points to note! id_rsa can cause a very big problem if it is shared, so keep it from being exposed if possible.


If you register id_rsa.pub value in ssh key in github, you can work without login.

If you add the id_rsa.pub key to the server account (~ / .ssh / authorized_keys) you want to connect to when you access ssh, you can connect at any time without login.


Example of regist authorized_key on your server

]$ cat ~/.ssh/id_rsa.pub | ssh [user_id]@[host] "cat > ~/.ssh/authorized_keys"


If you do this, you will be prompted to enter the password once.


In addition, when connecting to a server in a distribution system, etc., it is possible to attach to ssh at once without any cumbersome work.

Super cool to make your life more enriching!!


In a distributed system, if you register a private key as an environment variable and create id_rsa in the distribution system

Sometimes spaces are entered randomly.

At this time, the processing can be simplified. In my case, I did not write a quotation mark, so it was confirmed that a blank space was entered.


]$ echo "$SSH_KEY" > ssh-add


ssh-add is the role that registers the key to use.

If you have created and registered a key and asked for a password even though you registered it, simply run ssh-add.

If you get an error saying that there is no connetion, you can run the code below.


]$ eval $(ssh-agent -s)


'Develop > Linux' 카테고리의 다른 글

패키지 관리자가 느려지는 경우  (0) 2018.01.10
[Linux] 현재 날짜 추출하기  (0) 2018.01.08
[Linux] 블루투스 키보드 fnkey 사용법  (0) 2017.07.26
[SVN] commit merge info  (0) 2014.10.23
[Apache] Apache Benchmark  (0) 2014.04.03