Network_Automation
Ssh from Windows to Ubuntu without Password

To add your SSH key to the authorized keys on an Ubuntu server from a Windows machine, you can use the following steps:

Step 1: Generate SSH Key Pair (if not done already)

If you don't have an SSH key pair, generate one using the following command in PowerShell or Command Prompt:

ssh-keygen -t rsa -b 4096

Step 2: Copy the Public Key

Copy the public key to the clipboard. You can use the following command:

Get-Content ~/.ssh/id_rsa.pub | clip

Step 3: Connect to Ubuntu Server

Use an SSH client to connect to your Ubuntu server. You can use the built-in OpenSSH client on Windows or use a tool like PuTTY.

ssh username@your_server_ip

Step 4: Navigate to the SSH Directory

Once connected, navigate to the ~/.ssh directory on the Ubuntu server:

cd ~/.ssh

Step 5: Open the Authorized Keys File

Use a text editor like nano or vim to open the authorized_keys file:

vim authorized_keys

Step 6: Paste the Public Key

Paste the public key into the authorized_keys file. Save and exit the text editor.

Step 7: Set Proper Permissions

Ensure that the permissions on the ~/.ssh directory and authorized_keys file are set correctly:

chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

Step 8: Restart SSH (Optional)

If you faced any issues, you can restart the SSH service:

sudo service ssh restart

Step 9: Test the Connection

Try to log in using your SSH key:

ssh -i ~/.ssh/id_rsa username@your_server_ip

Replace username and your_server_ip with your actual username and server IP.

You should now be able to log in without entering a password.

Remember, if you are using a tool like PuTTY, you may need to convert your private key using PuTTYgen before connecting.