Skip to content

Latest commit

 

History

History
30 lines (26 loc) · 1.09 KB

ssh_key_setup.md

File metadata and controls

30 lines (26 loc) · 1.09 KB

How to access server via ssh and setup ssh key for passwordless authentication

Without setting up SSH Key It will ask Password each time we try to get access

  • To Get Access via SSH
Syntax:- ssh -p PORT USERNAME@HOSTIP
Example:- ssh -p 21350 [email protected]

Note:- Run Below Commands on Your Local Machine, Not on Your VPS or Remote Server

  • Generate SSH Key
ssh-keygen -f C:\Users\R/.ssh/my_key -t rsa -b 4096
  • Copy SSH Public Key to Remote Server (Not for Windows)
Syntax:- ssh-copy-id -p PORT -i ~/.ssh/keyname.pub USERNAME@HOSTIP
Example:- ssh-copy-id -p 21350 -i ~/.ssh/id_rsa.pub [email protected]
  • Copy Public Key to Remote Server (for Windows)
1. Make sure you have .ssh folder in remote server
Syntax:- ssh -P PORT USERNAME@HOSTIP "mkdir /home/USERNAME/.ssh"
Example:- ssh -P 21350 [email protected] "mkdir /home/u27653/.ssh"

2. Copy Public Key
Syntax:- scp -P PORT SSH_PUBLIC_KEY_PATH USERNAME@HOSTIP:/home/USERNAME/.ssh/authorized_keys
Example:- scp -P 21350 C:\Users\R/.ssh\id_rsa.pub [email protected]:/home/u27653/.ssh/authorized_keys