SSH means secure shell. Below is its definition from Wikipedia:
Secure Shell ( SSH ) is a cryptographic network protocol for operating network services securely over an unsecured network. Typical applications include remote command-line login and remote command execution, but any network service can be secured with SSH.
SSH mechanism
SSH uses RSA (非对称加密) to transfer information over the network. It provides two levels of authentication.
- Based on password. In order to login the server remotely, account and password need to be provided.
- Based on secret key. A pair keys (public and private) should be generated. Then place the public key on the remote server. You can login the server directly without inputting the password.
SSH default port: 22. The port can be specified via -p parameter.
ssh -p 23 qyh@192.168.0.1
Login via public key
- Generate key
ssh-keygen -t rsa -C "qyh@example.com"
associate the key with your email helps you to identify the key later
under the directory of /home/current account/.ssh, there are two key files generated, include id_rsa (private key) and id_rsa.pub (public key)
- Copy the public key to the remote server
ssh-id-copy -i .ssh/id_rsa.pub qyh@192.168.0.1
the key file should be copy to ~/.ssh/authorized_keys file on the remote server.
Finally, you can login the remote server directly, no password is required to input.
网友评论