ssh setup

The Secure Shell Protocol (SSH) is a cryptographic network protocol for operating network services securely over an unsecured network. Its most notable applications are remote login and command-line execution.

SSH was designed for Unix-like operating systems as a replacement for Telnet and unsecured remote Unix shell protocols, such as the Berkeley Remote Shell (rsh) and the related rlogin and rexec protocols, which all use insecure, plaintext methods of authentication, like passwords.

安全外殼協定(Secure Shell Protocol,簡稱SSH)是一種加密的網路傳輸協定,可在不安全的網路中為網路服務提供安全的傳輸環境[1]。SSH通過在網路中建立安全隧道來實現SSH客戶端與伺服器之間的連線[2]。SSH最常見的用途是遠端登入系統,人們通常利用SSH來傳輸命令列介面和遠端執行命令。SSH使用頻率最高的場合是類Unix系統,但是Windows作業系統也能有限度地使用SSH。2015年,微軟宣布將在未來的作業系統中提供原生SSH協定支援[3],Windows 10 1803版本已提供OpenSSH工具

Generate a key pair

In you local PC,

1
2
3
$ ssh-keygen
or
$ ssh-keygen -t rsa

where -t rsa option specifies that the type of the key should be RSA. Other choices include DSA, ECDSA, and ED25519. Select the protocol your SSH connection will use.

and id_rsa/id_rsa.pub are generated on .ssh.

  • id_rsa contains the private key.
  • id_rsa.pub contains the public key.

id_rsa.pub

Copy id_rsa.pub to remote machine .ssh/authorized_keys

ssh login without password

In your SSH session with the remote machine, update the permissions of the .ssh directory and authorized_keys file in case they need it:

1
2
$ chmod 700 ~/.ssh
$ chmod 600 ~/.ssh/authorized_keys

Now, close your connection and your Terminal or Command Prompt. When you reopen it and try to connect to the remote server again from the client where you have your private key saved, you should receive a request to enter the passphrase instead of your username and password.

Reference: 1. How to Set Up SSH Passwordless Login (Step-by-Step Tutorial)


ssh setup
https://waipangsze.github.io/2024/06/05/ssh/
Author
wpsze
Posted on
June 5, 2024
Updated on
October 8, 2024
Licensed under