両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン |
linux:openssh:client [2025/02/28 10:07] – [サーバーへの接続] ともやん | linux:openssh:client [2025/03/02 06:13] (現在) – [リモートマシンから切断されて ssh がフリーズする🤪] ともやん |
---|
| |
===== 公開/秘密キーのペアの生成 ===== | ===== 公開/秘密キーのペアの生成 ===== |
<WRAP prewrap 100%> | Linux or Mac では ssh-keygen を使用して、公開/秘密キーのペアを生成する。\\ |
* Linux or Mac では ssh-keygen を使用して、公開/秘密キーのペアを生成する。\\ (-C オプションでコメントを付加しておくとよい)\\ -t オプションには暗号タイプを指定する。\\ -b オプションには暗号強度の bit 数を指定する。\\ \\ <WRAP prewrap 100%> | (-C オプションでコメントを付加しておくとよい)\\ |
ED25519 の場合 | <html><code>-t</code></html> オプションには暗号タイプを指定する。\\ |
| <html><code>-b</code></html> オプションには暗号強度の bit 数を指定する。\\ |
| |
| **ED25519 の場合**\\ |
<WRAP color_term> | <WRAP color_term> |
<WRAP color_command><code> | <WRAP color_command><html><pre> |
$ ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519_tomoyan -C "Tomoyan Ed25519" | <font color="#0087FF"><b>$</b></font> <font color="#26A269">ssh-keygen</font> <font color="#A347BA">-t</font> ed25519 <font color="#A347BA">-f</font> ~/.ssh/id_ed25519_tomoyan <font color="#A347BA">-C</font> <font color="#A2734C">"Tomoyan Ed25519"</font> |
</code></WRAP> | </pre></html></WRAP> |
<WRAP color_result><html><pre> | <WRAP color_result><html><pre> |
Generating public/private ed25519 key pair. | Generating public/private ed25519 key pair. |
</WRAP> | </WRAP> |
| |
ECDSA の場合 | **ECDSA の場合**\\ |
<WRAP color_term> | <WRAP color_term> |
<WRAP color_command><code> | <WRAP color_command><html><pre> |
$ ssh-keygen -t ecdsa -b 521 -f ~/.ssh/id_ecdsa_tomoyan -C "Tomoyan ECDSA" | <font color="#0087FF"><b>$</b></font> <font color="#26A269">ssh-keygen</font> <font color="#A347BA">-t</font> ecdsa <font color="#A347BA">-b</font> 521 <font color="#A347BA">-f</font> ~/.ssh/id_ecdsa_tomoyan <font color="#A347BA">-C</font> <font color="#A2734C">"Tomoyan ECDSA"</font> |
</code></WRAP> | </pre></html></WRAP> |
<WRAP color_result><html><pre> | <WRAP color_result><html><pre> |
Generating public/private ecdsa key pair. | Generating public/private ecdsa key pair. |
</WRAP> | </WRAP> |
| |
RSA の場合 | **RSA の場合**\ |
<WRAP color_term> | <WRAP color_term> |
<WRAP color_command><code> | <WRAP color_command><html><pre> |
$ ssh-keygen -t rsa -b 2048 -f ~/.ssh/id_rsa_tomoyan -C "tomoyan rsa" | <font color="#0087FF"><b>$</b></font> <font color="#26A269">ssh-keygen</font> <font color="#A347BA">-t</font> rsa <font color="#A347BA">-b</font> 2048 <font color="#A347BA">-f</font> ~/.ssh/id_rsa_tomoyan <font color="#A347BA">-C</font> <font color="#A2734C">"tomoyan RSA"</font> |
</code></WRAP> | </pre></html></WRAP> |
<WRAP color_result><html><pre> | <WRAP color_result><html><pre> |
Generating public/private rsa key pair. | Generating public/private rsa key pair. |
</pre></html></WRAP> | </pre></html></WRAP> |
</WRAP> | </WRAP> |
| |
秘密キーはパーミッション: <nowiki>600(rw- --- ---)</nowiki>で ~/.ssh/id_rsa_tomoyan に生成される。\\ | 秘密キーはパーミッション: <nowiki>600(rw- --- ---)</nowiki>で ~/.ssh/id_rsa_tomoyan に生成される。\\ |
公開キーはパーミッション: <nowiki>644(rw- r-- r--)</nowiki>で ~/.ssh/id_rsa_tomoyan.pub に生成される。\\ \\ | 公開キーはパーミッション: <nowiki>644(rw- r-- r--)</nowiki>で ~/.ssh/id_rsa_tomoyan.pub に生成される。\\ \\ |
その場合は、パーミッションを正しく設定しなおす。 | その場合は、パーミッションを正しく設定しなおす。 |
<WRAP color_term> | <WRAP color_term> |
<WRAP color_command><code> | <WRAP color_command><html><pre> |
$ chmod 600 ~/.ssh/id_rsa_tomoyan | <font color="#0087FF"><b>$</b></font> <font color="#26A269">chmod</font> 600 <u style="text-decoration-style:solid">~/.ssh/id_rsa_tomoyan</u> |
</code></WRAP> | </pre></html></WRAP> |
</WRAP> | |
| |
</WRAP> | |
</WRAP> | </WRAP> |
| |
</WRAP> | </WRAP> |
| |
==== リモートマシンから切断されて ssh がフリーズする🤪 ==== | ===== リモートマシンから切断されて ssh がフリーズする🤪 ===== |
ssh エスケープ文字 <html><code>~</code></html> につづけて <html><code>.</code></html> で切断できる😉\\ | ssh エスケープ文字 <html><code>~</code></html> につづけて <html><code>.</code></html> で切断できる😉\\ |
<WRAP color_term> | <WRAP color_term> |