How to Use Upload File With Private Key
An SSH key is a grade of authentication in the SSH protocol. It is similar to a password, but allows for authentication without entering in a password or any transmission input. SSH keys by and large speaking are more secure, and convenient than countersign authentication.
Generating Keys
Command Line
If yous currently have access to SSH on your server, you tin generate SSH keys on the command line using thessh-keygen
utility which is installed by default on our servers. Run it on your server with no options, or arguments to generate a 2048-bit RSA cardinal pair (which is enough secure).
You will be prompted to select a file for the cardinal pair. The default directory for SSH keys is~/.ssh
with the individual central namedid_rsa
and the public key namedid_rsa.pub
. By using the default file names, the SSH client will be able to automatically locate the keys during authentication then information technology is strongly recommended to not change them. You can utilise the default by pressing the Enter key.
Generating public/private rsa key pair. Enter file in which to save the key (/home/USER/.ssh/id_rsa):
If /home/USER/.ssh/id_rsa
or a fundamental of the name you chose already exists, y'all will be prompted to overwrite the keys. If y'all do overwrite the existing keys, y'all will not be able to use them to cosign anymore.
Subsequently you accept selected the file for the central pair, you exist volition be prompted to enter a passphrase to encrypt individual key file. Encrypting the individual key with a passphrase isoptional, but it will improve security the keys. If you enter a passphrase you lot will have to provide each it fourth dimension y'all use the key. Y'all tin press the Enter key to not employ a passphrase; nosotros strongly recommend the apply of a passphrase with SSH keys.
Created directory '/dwelling house/USER/.ssh'. Enter passphrase (empty for no passphrase): Enter aforementioned passphrase again:
A public and private key volition at present be generated.
Your identification has been saved in /home/USER/.ssh/id_rsa. Your public central has been saved in /root/.ssh/id_rsa.pub. The central fingerprint is: SHA256:boo2WmwU41qy/IxmJCgDjjsg7xvvcXmHhHa7BKhoCPY root@server.domain.tld The central's randomart image is: +---[RSA 2048]----+ | | |o | |+. . . . | |=o. o . + o | |O+.. = .S= o | |X=oEo o.o = + | |*+= . ooo o | |oO+. ..o . | |*+.+. . | +----[SHA256]-----+
WHM
You can generate SSH fundamental pairs forroot
inWHM >> Home Security Centre >> Manage root'south SSH Keys.
Click Generate a New Key to go started.
There are several fields on this folio:Key Name,Key Password,Key Blazon, andFundamental Size.
The defaultFundamental Proper noun isid_rsa
. Keys are generated in/root/.ssh/
so the default key proper noun would create a private key in/root/.ssh/id_rsa
, and a public key in/root/.ssh/id_rsa.pub
. Using the default name will permit SSH clients to automatically locate the keys so it is strongly recommend you use the default name (simply leave the field bare or make full it withid_rsa
).
TheCardinal Password encrypts the private key file using a password to add together an extra layer of security. The password must be provided each fourth dimension the fundamental is used for authentication to decrypt the individual key. ThePassword Force field indicates how strong your password is. 0 indicates a very weak password, and 100 indicates a very stiff password. ClickPassword Generator to accept a stiff password generated for you.
Key Type andFundamental Size are RSA and 2048 by default, and are secure enough for most purposes then these tin can be left lone.
ClickGenerate Key to generate the SSH key pair. WHM will then brandish the location of the primal.
PuTTY
PuTTY is an open Windows SSH client. You will need to take the PuTTYgen utility installed to generate an SSH key pair. PuTTYgen is included in Windows installer on the Download PuTTY site, but you can download it separately if yous installed PuTTY without its extra utilities. See Connect using PuTTY to a Linux Server to acquire more about PuTTY.
Open up PuTTYgen.
TheParameters at the bottom tin be adjusted to touch how secure the central is, only the default options are plenty secure for well-nigh purposes.
If you're satisfied with the parameters, clickGenerate inActions to generate the key pair.
Y'all may be asked to "generate some randomness by moving the mouse over the blank area" to generate the key. The randomness is used to generate your keys securely, and make it difficult to reproduce them.
One time the key is generated, you lot will see the public central in PuTTYgen.
TheKey passphrase field sets a password used to decrypt the individual the key. This field is optional, and the individual key volition not exist encrypted if it is omitted.Using a passphrase increases the security of your SSH keys, and we strongly recommend setting one.
Exist sure to salvage both the public and private keys on your local machine so they can be used past PuTTY for hallmark in the future by clicking theRelieve public key andSave individual primal buttons.
If you don't apply a passphrase, it volition prompt you to confirm before allowing y'all to save the individual key. The private key volition be saved as a.ppk
file. The public primal isn't given an extension by default, just.pub
is a common extension for public key files. It tin be saved as a.txt
file besides every bit the public key file only stores the public key in plainly text.
Uploading Keys
Command Line
If you currently have admission to SSH on your server, you lot can upload the key over the command line.
Recollect the contents of the public central. If the key was created in the default location, this can be washed by outputting the contents of~/.ssh/id_rsa.pub
.
The output volition look like to the following:
ssh-rsa AAAAB9NzaC1yc2EAAAADAQABAAABAQDBej/3XAjhwTwWXsOJmDdKTLtjnpGXsHOAEIYC12qQ r51+AVJPNsqcDlFdv+Lr/XufQDCh2gXz+ieA/LJNb5luxReaVVbKtvAONZgv8uLD1J8kzRXike3h9L53 oIo2j8Lt4fuzB8yAWkwBelurn4OWfk0K6gFXN86RgprKSPN3GbwG6MINAor7NwCHzJhVK9u6Jpw9EPJv Dl4co+N9L+CGgudvY7iBNzIofE9MP68lXcql4bMWz3+2H0FWKHZ1rSJz56KjoCKBPWTqdFq5o1AIcauc ECgiTaEGcSNk4+T0A8BuAOd3a4O9Gr6y8C4Sn4ghYajJVWsszP2B1tTGAc3L
Open the (and create if it doesn't be)~/.ssh/authorized_keys
file using a text editor such equallynano
,pico
, orvim
.
$ nano ~/.ssh/authorized_keys
If you had to create the ~/.ssh/
directory, or the authorized_keys
file, you lot demand to verify the permissions are correct, or you won't exist able to login.
$ chmod 600 ~/.ssh/authorized_keys
Paste the public key at the bottom of the file, and so save and close the file.
Alternatively, y'all can append the public key to~/.ssh/authorized_keys
with a unmarried command.
You can use thetrue cat
command if the public primal is stored in a file.
$ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
If the public central is not stored every bit a file on the server, you can utilize theecho
command.
$ repeat "ssh-rsa AAAAB9N...sszP2B1tTGAc3L" >> ~/.ssh/authorized_keys
Be sure to include the entire public key in quotes laterecho
.
Once the public key is added to theauthorized_keys
file, you should be able to login using your SSH keys.
WHM
You can import an existing SSH key forroot
inWHM >> Habitation Security Center >> Manage root's SSH Keys.
ClickImport Primal.
The side by side folio has a few fields to fill up in.
Y'all need to name the SSH key in theChoose a name for this key field. The default key name isid_rsa
. Using the default proper noun volition let SSH clients to automatically locate the keys so it is strongly recommend yous use the default name (simply exit the field blank or fill information technology withid_rsa
).
If you are importing a PPK (PuTTYgen fundamental) file, enter its countersign (if applicable) in thePrivate key passphrase text box.
Paste the public central into the appropriate box, but donon paste the private key into the box; private keys should always remain on the servers that generated them.
ClickImport.
WHM volition brandish the name of the keys imported, from there y'all will demand to authorize the SSH key y'all merely imported past clicking "Manage Authorization" and "Authorize". In one case y'all have authorized the key you should now exist able to authenticate over SSH using the central.
Custom Key Names
The default name for SSH key pairs isid_rsa
, and that name will allow an SSH client to locate the key automatically. When an SSH cardinal pair doesn't utilise the default proper name, yous will demand to specify the name of key used.
$ ssh user@server.domain.tld -i /path/to/ssh/primal
Source: https://www.hostdime.com/kb/hd/linux-server/the-guide-to-generating-and-uploading-ssh-keys
0 Response to "How to Use Upload File With Private Key"
Postar um comentário