Set up passwordless ssh login to remote server

Yuwei BaoMarch 28, 2024


It is annoying to enter password every time when connecting to server using ssh. How can we avoid that?


ssh remote_username@server_ip_address

For the first time connecting to a server, you may see:

The authenticity of host 'server_ip_address' can't be established.
 key fingerprint is SOME_CONTENTS
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])?

Then enter password to connect.

That step will create some files in the path ~/.ssh/

Later on, to avoid entering password at each time logging in to the server, do the following:


  1. Generate SSH Public Key

Ref: in new window

  1. Add device ssh key to remote server

Ref1: in new window

Ref2: in new window

ssh-copy-id remote_username@server_ip_address

With entering password, there should be a notice

Number of key(s) added:        1

Then you can connect to server without password by doing ssh remote_username@server_ip_address 3. Make it even esier

nano ~/.ssh/config 

In the file ~/.ssh/config, write down

  HostName server_ip_address
  User remote_username

Then you can connect to server without password with the nickname ssh THE_SERVER_NICKNAME