📜  debian ssh authorized_keys - Shell-Bash (1)

📅  最后修改于: 2023-12-03 15:30:25.028000             🧑  作者: Mango

Debian SSH Authorized Keys

One of the most convenient and secure ways to access a remote server is through SSH. The process of setting up SSH involves creating a public and private key pair on your local machine, then adding the public key to the authorized_keys file on the remote server. This allows you to log in without needing to enter a password every time.

Setting up SSH Key Authentication on Debian
  1. Generate a key pair on your local machine using the ssh-keygen command. This will create a public key file (id_rsa.pub) and a private key file (id_rsa) in your ~/.ssh directory.
ssh-keygen
  1. Copy the public key to the remote server using the ssh-copy-id command. This will append the public key to the authorized_keys file on the remote server, creating the file if it does not already exist.
ssh-copy-id username@remote_server
  1. Test that you can log in without a password by using the ssh command with the -i option to specify your private key file.
ssh -i ~/.ssh/id_rsa username@remote_server
Managing Authorized Keys

The authorized_keys file contains a list of public keys that are authorized to log in to a user's account on the remote server. Each line in the file represents a single key.

To add a new key to the file, simply copy and paste the public key into a new line in the file.

To revoke access for a specific key, simply delete the corresponding line from the file.

Conclusion

SSH key authentication provides a secure and convenient way to access remote servers without needing to remember passwords. By following the steps outlined in this guide, you can easily set up and manage authorized keys on your Debian server.