SSH to Server#
Basic SSH connection
ssh username@hostname
SSH with specific port
ssh -p 2222 username@hostname
SSH to cloud server (example)
ssh ubuntu@server-ip-address
Common use cases:
- Replace
username
with your server username - Replace
hostname
with either the server's domain name or IP address - The
-p
flag allows you to specify a custom port when the server uses a non-standard SSH port (default is 22) - Cloud providers often use specific usernames (like 'ubuntu' for Ubuntu instances on AWS)
Git SSH Clone#
Clone private repository
git clone git@github.com:username/private-repo.git
Clone with specific SSH key
git clone -c core.sshCommand="ssh -i ~/.ssh/specific_key" git@github.com:username/repo.git
Git SSH cloning tips:
- Replace
username
with your GitHub username - Replace
private-repo
with your repository name - Using SSH keys with Git requires adding your public key to your GitHub account
- The specific key option is useful when you have multiple SSH keys for different services