Epoxsea Software Document Help

Secure Shell Protocol (SSH)

\#linux

  • 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 is mostly use for remote login

Create Login

  • user: username

  • host: remote host

create login

ssh user@host ssh host # you can omit the username, if local username and remotte username are the same

create login and access different port

ssh -p 2222 user@host

The default port for SSH is 22, you can change to access other port by this command

Remark: If you are first time to login the remote host, below prompt will appear

ssh user@host The authenticity of host 'host (12.18.429.21)' can't be established. RSA key fingerprint is 98:2e:d7:e0:de:9f:ac:67:28:c2:42:2d:37:16:58:4d. Are you sure you want to continue connecting (yes/no)?

which this mean can ensure the host authenticity, only know the RSA key fingerprint.

  • The key (here we use RSA) normally will be very hard to compare because of the length. So the RSA key fingerprint here is the RSA key hashed by MD5 which become 128 bit fingerprint, which is much easier to compare

  • The user need to know the remote host key fingerprint to confirm the authenticity. One normal way is the remote host upload the key fingerprint online and let the user check

If the user type yes, then it will appear

Warning: Permanently added 'host,12.18.429.21' (RSA) to the list of known hosts. Password: (enter password)

If the remote host public key is accepted, then it will be saved as $HOME/.ssh/known_hosts. Next time user will skipped the warning part and directly to the entering password part

Public Key Login

If you don't want to enter the password every time. Then you can use the public key login

Using ssh-keygen to Generate Public Key and Private Key

copy the public key to remote host

ssh-copy-id user@host

Remark: If still can't open the /etc/ssh/sshd_config in the remote host, make sure below code are not comment out

RSAAuthentication yes PubkeyAuthentication yes AuthorizedKeysFile .ssh/authorized_keys

restart the remote host ssh service

service ssh restart # ubuntu /etc/init.d/ssh restart # debian

Remark: Remote host will store user public key inside user's $HOME/.ssh/authorized_keys

Actually you can use this to store the public key

ssh user@host 'mkdir -p .ssh && cat >> .ssh/authorized_keys' < ~/.ssh/id_rsa.pub

The workflow of public key login

  1. The user stores his public key on the remote host. When login, the remote host will send a random string to the user

  2. The user encrypts it with his private key and then sends it back

  3. The remote host decrypts it with the public key stored in advance

  4. If it succeeds, it proves that the user is trustworthy and allows login to the shell directly without asking for a password

Last modified: 12 June 2025