Ssh-copy-id @. Where is the username that you want to log in as on the VPS, and is the IP address of the VPS. There are further things to add to this command if you have chosen a different name or location for your created ssh keys, or if your server uses a non-standard port for ssh.
Updated by LinodeWritten by Linode
Try this guide out by signing up for a Linode account with a $20 credit.
Contribute on GitHub
Report an Issue |View File |Edit File
Password authentication is the default method most SSH (Secure Shell) clients use to authenticate with remote servers, but it suffers from potential security vulnerabilities, like brute-force login attempts. An alternative to password authentication is public key authentication, in which you generate and store on your computer a pair of cryptographic keys and then configure your server to recognize and accept your keys. Using key-based authentication offers a range of benefits:
This guide will explain how the SSH key login scheme works, how to generate an SSH key, and how to use those keys with your Linode.
Note
If you’re unfamiliar with SSH connections, review the Getting Started with Linode guide.
How SSH Keys Work
SSH keys are generated in pairs and stored in plain-text files. The key pair (or keypair) consists of two parts:
When a site or service asks for your SSH key, they are referring to your SSH public key (
id_rsa.pub ). For instance, services like GitHub and Gitlab allow you to place your SSH public key on their servers to streamline the process of pushing code changes to remote repositories.
The authorized_keys File
In order for your Linode to recognize and accept your key pair, you will need to upload your public key to your server. More specifically, you will need to upload your public key to the home directory of the user you would like to log in as. If you would like to log in to more than one user on the server using your key pair, you will need to add your public key to each of those users.
To set up SSH key authentication for one of your server’s users, add your public key to a new line inside the user’s
authorized_keys file. This file is stored inside a directory named .ssh/ under the user’s home folder. A user’s authorized_keys file can store more than one public key, and each public key is listed on its own line. If your file contains more than one public key, then the owner of each key listed will be able to log in as that user.
Granting Someone Else Access to your Server
To give someone else access to your server’s user, simply add their public key on a new line in your
authorized_keys file, just as you would add your own. To revoke access for that person, remove that same line and save the changes.
Challenge-Response
When logging in to a server using SSH, if there is a public key on file on that server, the server will create a challenge. This challenge will be crafted in such a way that only the holder of the private SSH key will be able to decipher it.
This challenge-response action happens without any user interaction. If the person attempting to log in has the corresponding private key, then they will be safely logged in. If not, the login will either fail or fall back to a password-based authentication scheme.
SSH Key Passphrases
You can optionally provide an additional level of security for your SSH keys by encrypting them with a passphrase at the time of creation. When you attempt to log in using an encrypted SSH key, you will be prompted to enter its passphrase. This is not to be confused with a password, as this passphrase only decrypts the key file locally and is not transferred over the Internet as a password might be.
If you’d like to set up your logins so that they require no user input, then creating a passphrase might not be desirable, but it is strongly recommended nevertheless.
Linux and macOSGenerate a Key Pair
Perform the steps in this section on your local machine.
Upload your Public Key
There are a few different ways to upload your public key to your Linode from Linux and macOS client systems:
Using ssh-copy-idssh-copy-id is a utility available on some operating systems that can copy a SSH public key to a remote server over SSH.
Using Secure Copy (scp)
Secure Copy ( Caution
scp ) is a tool that copies files from a local computer to a remote server over SSH:
These instructions will overwrite any existing contents of the
authorized_keys file on your server. If you have already set up other public keys on your server, use the ssh-copy-id command or enter your key manually.
Manually Copy an SSH Key
You can also manually add an SSH key to a server:
Connect to the Remote Server
Windows
The following instructions use the PuTTY software to connect over SSH, but other options are available on Windows too.
Generate a Key Pair with PuTTY
Manually Copy the SSH Key with PuTTY
Using WinSCP
Uploading a public key from Windows can also be done using WinSCP:
Generate A Ssh Key To Login To My Vps AccessCaution
These instructions will overwrite any existing contents of the
authorized_keys file on your server. If you have already set up other public keys on your server, use the PuTTY instructions instead.
Connect to the Remote Server with PuTTY
Start PuTTY and Load your saved session. You’ll be prompted to enter your server user’s login name as before. However, this time you will be prompted for your private SSH key’s passphrase rather than the password for your server’s user. Enter the passphrase and press Enter.
Troubleshooting
If your SSH connections are not working as expected, or if you have locked yourself out of your system, review the Troubleshooting SSH guide for troubleshooting help.
Upload your SSH Key to the Cloud Manager
It is possible to provision each new Linode you create with an SSH public key automatically through the Cloud Manager.
Next Steps
After you set up your SSH keys and confirm they are working as expected, review the How to Secure Your Server guide for instructions on disabling password authentication for your server.
Generate A Ssh Key To Login To My Vps PasswordJoin our Community
Please enable JavaScript to view the comments powered by Disqus.comments powered by Disqus
This guide is published under a CC BY-ND 4.0 license.
An SSH Key allows you to log into your server without needing a password. SSH Keys can be automatically added to servers during the installation process.
Creating an SSH key on Windows
The simplest way to create SSH key on Windows is to use PuTTYgen.
Creating an SSH key on Linux
The tools to create and use SSH are standard, and should be present on most Linux distributions. With the following commands, you can generate ssh key.
Generate A Ssh Key To Login To My Vps OnlineAdding an SSH key to your control panelGenerate A Ssh Key To Login To My Vps Server
Limitations
Connecting to a server using an SSH key from a Windows client
Connecting to a server using an SSH key from a Linux client
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
November 2020
Categories |