Step 1: Create public and private keys using ssh-key-gen on local-host
ssh-keygen
Step 2: Copy the public key to remote-host using ssh-copy-id
ssh-copy-id user@hostname.example.comor if you want to specify the public key file
ssh-copy-id -i ~/.ssh/id_rsa.pub user@hostname.example.com
ssh-keygen
Step 2: Copy the public key to remote-host using ssh-copy-id
ssh-copy-id user@hostname.example.comor if you want to specify the public key file
ssh-copy-id -i ~/.ssh/id_rsa.pub user@hostname.example.com
What ssh-copy-id did is basically copying the content in the ~/.ssh/id_rsa.pub to the ~/.ssh/authorized_keys in remote server.
If you want to make the login even quicker, you can set an alias in the .bashrc, like
alias host="ssh user@hostname.example.com"
Next time, you just need to type host, which will bring you directly to the host. Easy?
btw, if ssh-copy-id is not found for your system (e.g. default case in Mac OS), you can easily install it by using:
brew install ssh-copy-id
btw, if ssh-copy-id is not found for your system (e.g. default case in Mac OS), you can easily install it by using:
brew install ssh-copy-id
No comments:
Post a Comment