An SSH config file (~/.ssh/config, or C:\Users\YourUser\.ssh\config on Windows) saves connection settings for each server, so a short ssh myserver replaces a long command. Each Host block sets the server address, user, port and key:
Host myserver
HostName 203.0.113.10
User deploy
Port 22
IdentityFile ~/.ssh/id_ed25519
Below: creating the file on Windows and Linux, logging in with an alias, and using the same file for GitHub clone and pull.
To Ease Remote Server Login from a Windows Machine
-
Create the SSH Config File
- Open Notepad and save the file with the filename
configat the pathC:\Users\YourUser\.ssh. - Convert the newly created config text file to a config file:
cd c:\users\yourUser\.ssh copy config.txt config del config.txt
- Open Notepad and save the file with the filename
-
Edit the Config File
-
Open
configusing Notepad or Notepad++. -
Add the following credentials, then save the file:
Syntax:
Host ANY_NAME_1 HostName SERVER_IP or SERVER_DOMAIN User SERVER_USERNAME Port SERVER_PORT IdentityFile ~/.ssh/YOUR_PVT_SSH_KEY_NAME IdentitiesOnly yesExample:
Host geek-vps-ubuntu HostName 181.219.74.228 User rajesh Port 1037 IdentityFile ~/.ssh/raj_ed25519 IdentitiesOnly yes -
You can add as many
Hostentries as needed to manage multiple servers and their respective SSH keys.
-
-
Use the Config File
-
Now, you can use the
Hostalias to log in to the remote server via CMD or terminal:ssh HOSTExample:
ssh geek-vps-ubuntu
-
To Ease GitHub Clone and Pull Operations from a Linux Machine
-
Access the Remote Server via SSH
- Syntax:
ssh -p PORT USERNAME@HOSTIP - Example:
ssh -p 22 [email protected] - OR
- Syntax:
ssh HOST - Example:
ssh geek-vps-ubuntu
- Syntax:
-
Create the SSH Config File
-
Create the file:
touch ~/.ssh/config -
Edit the config file using
nano:nano ~/.ssh/config -
Add the following credentials, then save the file:
Syntax:
Host ANY_NAME_1 HostName GITHUB_IP or GITHUB_DOMAIN User GITHUB_USERNAME IdentityFile ~/.ssh/YOUR_PVT_SSH_KEY_NAME IdentitiesOnly yesExample:
Host react_project HostName github.com User geekyshow1 IdentityFile ~/.ssh/react_ed25519 IdentitiesOnly yes -
You can add as many
Hostentries as needed to manage multiple GitHub repositories and their respective SSH keys.
-
-
Use the Config File for Git Operations
-
Verify Connection:
ssh -T git@HOSTExample:
ssh -T git@react_project -
Clone Git Repo:
git clone git@HOST:GITHUB_USERNAME/REPO_NAMEExample:
git clone git@react_project:geekyshow1/ecomm.git -
Git Pull:
git pull
-
