linuxサーバは秘密鍵ファイルを使用してSSHログインを行う
linuxはssh keyを使用してログインします
1.keyの作成
2.公開鍵をvpsにインポート
3.SSHDのプロファイルの変更/etc/ssh/sshd_config
4.SSHサービスを再起動してテストを行う
5.テスト完了後rootユーザーパスワード登録を閉じる
6.保存再起動秘密鍵のバックアップ後、サーバ側の秘密鍵 を削除する.
ブログを参照:http://blog.iefer.com/
1.keyの作成
ssh-keygen -t rsa #
# Enter file in which to save the key (/root/.ssh/id_rsa): #
# Enter passphrase (empty for no passphrase): #
# Enter same passphrase again: #
# Your identification has been saved in /root/.ssh/id_rsa.
# Your public key has been saved in /root/.ssh/id_rsa.pub.
# The key fingerprint is:
# SHA256:BQLRxhkpfq6H4LdXrAInx/nFS7OFqb+MmyoCBABkVUI root@Fuyoo
# The key's randomart image is:
# +---[RSA 2048]----+
# |*ooE+*o+. |
# |o o *. . |
# |. . o . |
# | . . . . |
# |. . + oSo |
# |. + = . X . |
# |.. * + * = |
# |. o = *+o |
# | . oo*+o+. |
# +----[SHA256]-----+
2.公開鍵をvpsにインポート
cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys
3.SSHDのプロファイルの変更/etc/ssh/sshd_config
#RSAAuthentication yes #
#PubkeyAuthentication yes #
#AuthorizedKeysFile .ssh/authorized_keys #
4.SSHサービスを再起動してテストを行う
service sshd restart
5.テスト完了後rootユーザーパスワード登録を閉じる
PasswordAuthentication yes # PasswordAuthentication no
6.保存再起動
service sshd restart
ブログを参照:http://blog.iefer.com/