[Simple procedure] To log in to ssh without a password

A note on ssh connection from macOS Catalina to CentOS7.7. Obviously, it can be used not only on macOS but also on linux and * BSD environments.

Client (macOS) side work

Shell command


mkdir -m 0700 ~/.ssh
ssh-keygen

The passphrase is enter key only. Then, the private key (id_rsa) and public key (id_rsa.pub) are generated in the .ssh directory under the home directory.

~/.ssh ┣ id_rsa ┗ id_rsa.pub

Copy the public key to the server.

Shell command


cd ~/.ssh
scp id_rsa.pub (Username on the server)@Server IP:.

Log in to the server once with ssh.

Shell command


ssh (Username on the server)@Server IP

Server side work

Register the public key.

Shell command


mkdir -m 0700 ~/.ssh
cd ~/.ssh
cat ~/id_rsa.pub >> authorized_keys
chmod 0600 authorized_keys

Set up public key authentication on the server.

Shell command


vi /etc/ssh/sshd_config

Modify as follows. #PubkeyAuthentication yes  ▼ PubkeyAuthentication yes

Restart sshd.

Shell command


service sshd restart

Now you can ssh login from the client side to the server without password authentication.

that's all.

Recommended Posts

[Simple procedure] To log in to ssh without a password
Log in to Raspberry PI with ssh without password (key authentication)
Allow sudo to run apt without a password
Log in to the remote server with SSH
How to use GitHub on a multi-person server without a password
It's hard to write a very simple algorithm in php
A simple way to avoid multiple for loops in Python
How to log in automatically like 1Password from the CLI
A simple way to launch Jupyter Notebook / Lab and set a password
Implementing a simple algorithm in Python 2
Run a simple algorithm in Python
How to log in to Docker + NGINX
A simple HTTP client implemented in Python
I want to print in a comprehension
Try drawing a simple animation in Python
Create a simple GUI app in Python
Log in to Slack using requests in Python
A simple IDAPython script to name a function
How to get a stacktrace in python
Write a simple greedy algorithm in Python
[V11 ~] A memorandum to put in Misskey
Write a simple Vim Plugin in Python 3
I created a password tool in Python.
Build a PYNQ environment on Ultra96 V2 and log in to Jupyter Notebook
Launch a simple password-protected search service in 5 minutes
A simple example of how to use ArgumentParser
Try to calculate a statistical problem in Python
How to clear tuples in a list (Python)
To execute a Python enumerate function in JavaScript
How to embed a variable in a python string
I want to create a window in Python
How to create a JSON file in Python
A clever way to time processing in Python
How to implement a gradient picker in Houdini
Steps to develop a web application in Python
Log in to Yahoo Business with Selenium Python
A simple Pub / Sub program note in Python
Easily log in to AWS with multiple accounts
Build a simple Python virtual environment without pyenv
To add a module to python put in Julialang
Create a simple momentum investment model in Python
How to notify a Discord channel in Python
Set up a simple SMTP server in Python
[Python] How to draw a histogram in Matplotlib
How to create a Rest Api in Django
Insert a date without line breaks in CotEditor
How to write a named tuple document in 2020
How to count numbers in a specific range
Use pygogo to get the log in json.
How to read a file in a different directory
A supplement to "Camera Calibration" in OpenCV-Python Tutorials
Create a command to get the work log
How to Mock a Public function in Pytest