Preparation Knowledge

SSH is a very useful tool which supports to use all kinds of commands to control remote computer for developers.
Before interacting with the server, users are required to login with a username and password to be certified.
But it’s inconvenient for us to input password every time we want to login remote server.
Actually, it’s possible to login by ssh without input password.
The rest of the article shows the way to achieve it.



How To Do it

ssh-keygen is a recommended tool to generate ssh private/public key based on the RSA encrypt algorithm.

$ ssh-keygen -t rsa

Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/weiyang/.ssh/id_rsa.
Your public key has been saved in /Users/weiyang/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:m5XTl5uKeD9C7urY6Etx34RaG/gbhgIM4owCYeVVczQ [email protected]
The key's randomart image is:
+---[RSA 2048]----+
|.... ..o.E |
...
| .=o=++oo. |
+----[SHA256]-----+

We got identification and public key in folder ~/.ssh after that.
Create a simple file ~/.ssh/authorized_keys on the server and copy the content of ~/.ssh/id_rsa.pub on local PC to it.
You can use an FTP client tool to upload a local authorized_keys to the server or rewrite it on ssh client, the copy method depends on you.
After that, we login server by ssh without password any more.

$ ssh [email protected] -p portNumer



Categories: Shell

0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
A prohibited operation
0
Would love your thoughts, please comment.x
()
x