Example:
server_node
client_node
server_node to client_node
Generate private and public keys from server
server_node$: ssh-keygen
Leave all the setting default by pressing enter (you can also enter a strong passphrase for security)Send the key to the client
ssh-copy-id client_node
This is a shortcut to 1. copy the the public key (id_rsa.pub) to the client_node
server_node$: scp ~/.ssh/id_rsa.pub client_node/.ssh
2. copy the contend of id_rsa.pub from server_node to the list (authorized_key) in the client_node
client_node$: cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
Test whether it works
server_node$: ssh client_node
If you are required to enter password/passphrase, do the following
server_node$: sudo apt-get install keychain
Add the following to your ~/.bashrc (depend on your shell)
if type keychain >/dev/null 2>/dev/null; then
keychain --nogui -q id_rsa
[ -f ~/.keychain/${HOSTNAME}-sh ] && . ~/.keychain/${HOSTNAME}-sh
[ -f ~/.keychain/${HOSTNAME}-sh-gpg ] && . ~/.keychain/${HOSTNAME}-sh-gpg
If you encounter syntax problems, please check the indent, make sure the indent are 4 spaces.This is just one way process, if you want to mutual password-free, do it again on the client_node. OR copy your .ssh files file server_node to client_node.
NOTE: If you manually copy id_rsa.pub, be aware of not overriding the key, rename the name before transmitting.
No comments:
Post a Comment