[LINUX] Until you can borrow VPS with Conoha and authenticate public key with SSH

Work log from Mac to VPS connecting with SSH. It's not a big task, but I'll forget it soon, so make a note for myself

environment

Conoha VPS

Add a server in the Conoha Control Panel. This time, specify application: LAMP. At the moment it seems to be CentOS 8.

Create working user

Log in to the VPS from the client environment

Check the IP address from the details screen of the added server, and log in as the root user.

>>> ssh [email protected] -p 22

Create a working user on your VPS

# adduser tukanpo
# passwd tukanpo

Add the created user to the wheel group

# gpasswd -a tukanpo wheel

[Addition] Later added to the apache group

Edit sudo config file

# sudo visudo

If the second line is commented out, uncomment it

## Allows people in group wheel to run all commands
%wheel  ALL=(ALL)       ALL

Creating a private / public key

Log in to the server again as a working user

Log out of VPS

# exit

Login as a working user

>>> ssh [email protected] -p 22

Create a .ssh directory directly under the user's working directory

$ mkdir .ssh
$ chmod 700 .ssh

Log out and switch to client again

Create a key on the client

Create .ssh directory if not yet created

>>> cd ~
>>> mkdir .ssh
>>> chmod 700 .ssh
>>> cd .ssh

Generate a key (unnecessary if it already exists and can be reused)

>>> ssh-keygen -t rsa -b 2048

Copy the client's public key to the server

Copy the public key to authorized_keys on the server side

>>> scp id_rsa.pub [email protected]:~/.ssh/authorized_keys

Enable connection by host name

Edit the config file in the .ssh directory (create it if it doesn't exist)

>>> vi config

Add the following

Host tukanpo.net
  HostName xxx.xxx.xxx.xxx
  User tukanpo
  Port 22
  IdentityFile ~/.ssh/id_rsa

Connect to VPS with host name

>>> ssh tukanpo.net

end

Recommended Posts

Until you can borrow VPS with Conoha and authenticate public key with SSH
Ssh login with public key authentication quickly
[SSH] About public key authentication and EC2
Until you can use opencv with python
Until you can install blender and run it with python for the time being
[GitHub] Until you pull with ssh using Deploy keys
What you can and cannot do with Tensorflow 2.x
Until you can do simple image recognition with Jupyter
Until you can install your own Python library with pip
Set public key authentication when connecting with SSH in Teraterm
Try and learn iptables, until you can browse the web
Use ssh with private key public key authentication. Connect from wan.
If you make 1 billion private keys, you can make a public key including your name with high probability.
Ssh connection using public key
SSH public key authentication was set for Sakura VPS Cent OS 7.7
Until you build the environment with ABCI and run MaskTrack RCNN