To add your SSH public keys to the authorized_keys
file on a remote Linux server, follow these steps:
- Ensure OpenSSH is installed on your Windows machine.
- Locate your SSH public key files.
type C:\Users\ajhs\.ssh\id_ed25519.pub | ssh username@remote_server "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"
type C:\Users\ajhs\.ssh\id_ecdsa.pub | ssh username@remote_server "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"
type C:\Users\ajhs\.ssh\id_dsa.pub | ssh username@remote_server "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"
- Each command reads the content of the respective public key file using
type
. - The output is piped (
|
) to thessh
command, which connects to the remote server. - The remote command
mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys
ensures the.ssh
directory exists and appends the public key to theauthorized_keys
file.
Note: Replace username
with your remote server username and remote_server
with the IP address or hostname of your remote server.
This Markdown text box provides a clear and structured way to present the commands and their explanations.