Ssh Using Rsa Key



Log in with an SSH private key on Linux and macOS

Authored by: Brint Ohearn

This article demonstrates how to use a private key to log in to a Linux®server by using a private key with a Terminal session on macOS®. However,you can follow the same process to use a private key when using anyterminal software on Linux.

Note: For information about using Secure Shell (SSH) private keys on Microsoft®Windows® operating systems, seeLogging in with an SSH Private Key on Windowsand Generate RSA keys with SSH by using PuTTYgen.

Prerequisites

  • /.ssh/identity /.ssh/iddsa /.ssh/idrsa Contains the private key for authentication. These files contain sensitive data and should be readable by the user but not acces- sible by others (read/write/execute). Ssh will simply ignore a private key file if it is accessible by others.
  • Select Use existing public key in the dropdown for SSH public key source so that you can use the public key you just generated. Take the public key and paste it into your VM setup, by copying the entire contents of the idrsa.pub in the SSH public key. You also want to allow your VM to accept inbound SSH traffic by selecting Allow selected.
  • # ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/idrsa): (It's safe to press enter here, as the /root/.ssh is the default and recommended.

This tutorial explains how to use SSH Public key authentication against a VMware ESXi host.

Ssh Using Rsa Keyboard

To complete this process, you need the following software applications:

  • SSH client software that is installed on your Linux or macOS operating system by default.
  • Your favorite text editor. This example uses the vim text editor.
  • Your private key. For more information about generating a key on Linux or macOS, seeConnect to a server by using SSH on Linux or Mac OS X.
Ssh using rsa key generator

Log in with a private key

  1. Using a text editor, create a file in which to store your private key. This example usesthe file deployment_key.txt.

  2. To edit the file in vim, type the following command:

  3. After the editor starts, press i to turn on insert mode.

  4. Paste your private key, such as the one in the following image, into the file.Be sure to include the BEGIN and END lines.

  5. To save your changes, press Esc.

  6. Type :wq to write the file and return to the command line.

  7. Run the following command to change the file permissions to 600 to secure the key. You can also set them to 400.This step is required:

  8. Use the key to log in to the SSH client as shown in the following example, which loads the key in file deployment_key.txt, and logs in as user demo to IP 192.237.248.66:

  9. When you are prompted to confirm the connection, type yes and then press Enter.

  10. If your SSH key requires a password, enter it when prompted to complete the connection.

Share this information:

Ssh Using Rsa Private Key

©2020 Rackspace US, Inc.

Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License

У меня есть много серверов, для которых я правильно сгенерировал ключи, установил разрешения и смог ssh/scp без пароля.Однако есть одна машина, которая немного отличается, и я думаю, что я нашел разницу.

Разница в том, что на машине, к которой я не могу подключиться без пароля, ssh принимает ключи:

и все другие мои машины принимают:

При создании ключей ssh я всегда устанавливаю аргумент '-t rsa', и я не уверен, какой тип ключа генерируется. Можете ли вы помочь мне создать ключ ssh-rsa вместо rsa-sha2-512? И последнее: я не могу изменить /etc /ssh /sshd_config, чтобы что-то изменить.

Полный дамп журнала SSH приведен ниже: Один, к которому я могу подключиться:

Второй, к которому я не могу подключиться:

Команда, которую я использую для генерации ключа:

Я также пытался:

  • Создать ключ с разными параметрами:

    -t rsa1; -t экдса; -б 1024; -b 2048;