- 1 year ago
Configure Git Remote server with Putty For Windows Pc
To configure Git to work with a remote server using PuTTY on a Windows PC, you need to set up PuTTY as your SSH client and then configure Git to use PuTTY as the SSH executable. Here are the steps:
Download PuTTY and Pageant:
- Download PuTTY and Pageant from the official website: https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
- Install PuTTY and Pageant on your Windows PC.
Generate SSH Key with PuTTYgen:
- Open PuTTYgen from the Start menu.
- Click "Generate" to create a new SSH key pair. Move the mouse over the blank area to generate randomness.
- Save the private key (.ppk) and the public key (.pub) to a location on your PC.
Add the Public Key to the Remote Server:
- Copy the content of the public key file (e.g.,
id_rsa.pub
) to the remote server's~/.ssh/authorized_keys
file. You can use thessh-copy-id
command on the remote server or manually paste the content.
- Copy the content of the public key file (e.g.,
Add the Private Key to Pageant:
- Open Pageant from the Start menu.
- Click on the Pageant icon in the system tray, then choose "Add Key."
- Browse to the private key file (e.g.,
id_rsa.ppk
) and add it to Pageant. Enter the passphrase if you set one during key generation.
Configure Git to use PuTTY:
Open a Command Prompt (cmd) or Git Bash.
Set the
GIT_SSH
environment variable to point toplink.exe
(PuTTY's SSH client):cmdsetx GIT_SSH "C:\Program Files\PuTTY\plink.exe"
Note: If you installed PuTTY in a different location, adjust the path accordingly.
Clone or Configure Your Git Repository:
To clone a repository using the SSH URL, you can now use the
git clone
command:cmdgit clone git@your_remote_server:your_repo.git
If you already have a Git repository and want to change the remote URL to use SSH, use the following command:
cmdgit remote set-url origin git@your_remote_server:your_repo.git
Now Git on your Windows PC is set up to work with a remote server using PuTTY as the SSH client. You can push and pull changes to and from the remote repository using SSH without the need for username/password authentication each time (assuming you have set up the public key on the remote server correctly).