Setting up OpenSSH on Arch Linux

Installation

openssh Install the package.

# pacman -Syu openssh

By executing the following command, the SSH server will start automatically when the computer starts.

# systemctl enable sshd

Client settings

Create a ~ / .ssh directory and generate a private / public key pair.

# mkdir .ssh
# chmod 700 .ssh
# cd .ssh
# ssh-keygen -t rsa -b 4096 -C "{email}"

Transfer the public key to the server in some way.

scp ~/.ssh/id_rsa.pub {user}@{host}:/home/{user}/id_rsa.pub

To omit specifying the user name, port number, and private key when connecting to the server, create a ~ / .ssh / config file with the following contents.

~/.ssh/config


Host {host}
  HostName {host}
  IdentitiesOnly yes
  IdentityFile ~/.ssh/id_rsa
  Port {port}
  User {user}

Server settings

Add the client-created public key to ~ / .ssh / authorized_keys and set the permissions.

% mkdir ~/.ssh
% cat ~/id_rsa.pub >> ~/.ssh/authorized_keys
% rm -f ~/id_rsa.pub
% chmod 700 ~/.ssh
% chmod 600 ~/.ssh/authorized_keys

Make the following settings to enhance security.

/etc/ssh/sshd_config


#Change the port number from the default of 22 to prevent unauthorized access.
#Avoid using Well Known Ports and Ephemeral Ports, which are prone to collisions.
#Specifically 1024-It is recommended to select in the range of 32767.
Port {port}

#Login as the root user is completely prohibited.
#If you need administrator privileges, log in as a general user and use sudo.
PermitRootLogin no

#Authenticate with insecure passwords and always use the private key.
PasswordAuthentication no

Restart sshd for the settings to take effect.

# systemctl restart sshd

How to use

Log in to the server with the ssh command.

% ssh {host}

Use the scp command to transfer files.

% scp {localPath} {host}:{remotePath}

Recommended Posts

Setting up OpenSSH on Arch Linux
jblas on Arch Linux
Install Minecraft on Arch Linux
Setting up grub on CentOS 8
Downgrade Mcomix on Arch Linux
Install Arch Linux on DeskMini A300
Rip Music CDs on Arch Linux
Build an NFS server on Arch Linux
Basic usage of Btrfs on Arch Linux
Notes for setting up pydicom on macOS
Build a Samba server on Arch Linux
Until you install Arch Linux on VMware
Arch Linux Recommendation
Set up golang with goenv on GNU / Linux
Notes on setting up tensorflow-gpu on MacBook Pro (Mid 2012)
Cross-compile windows version from nim on arch | linux
Deliver OBS footage to Zoom on Arch Linux
Set up an Objective-C 2.0 development environment on Linux
Build an Arch Linux environment on Raspberry Pi
Daemonizing processes on Linux
How to use C216 Audio Controller on Arch Linux
Linux (WSL) on Windows
NAT router on Linux
[Note] The story of setting up the SDK for Python of Azure IoT Hub on Linux
Database autostart setting linux
Set up Docker on Oracle Linux (7.x) with Vagrant
Develop .NET on Linux
[Part 1] Let's set up a Minecraft server on Linux
Wake on lan on Linux
Monitor traffic on Linux
Install Docker on Arch Linux and run it remotely
Update vscode on linux
Try NeosVR on Linux
Check capacity on Linux
Arch Linux installation notes
[Linux] IPv6 invalidation setting
LiveUSB creation on Linux
Linux operation on Win10
Setting up a CentOS 7 server hosted on Alibaba Cloud ECS
Game distribution to YouTube Live on Arch Linux (Nintendo Switch)
NTP configuration memo on Linux
Set up Python 3.4 on Ubuntu
Install Linux on your Chromebox
Until docker-compose up on CentOS7
Monitor disk usage on Linux
Use Github Desktop on Linux
Install the JDK on Linux
Elixir = Comfortable on Linux Mint
Recording and playback on Linux
Check TTL on Linux router
Read core voltage on Linux
Put jenv on Amazon Linux
Easy df command on Linux
Set up Polyglot on Windows
Linux on Windows -1-: debian introduction
Install tomcat 5.5 on Amazon Linux.
Introducing Elixir on Linux Mint
Use sshpass on Amazon linux2
Install Homebrew on Amazon Linux 2
Paste the link on linux
Install strongSwan 5.9.1 on Amazon Linux 2