#!/linuxSucks/SSH Comand Examples

Apr 25, 2021

Secure shell (ssh) is cryptographic network protocol used for an encrypted connections between a client and a server.

SSH syntax

ssh [OPTIONS] [USER]@HOST

The most used ssh command

ssh user@000.000.000.000
ssh user@domain.xxx

The first time you connect to the server, you’ll see something like

The authenticity of host 'domain.xxx (000.000.000.000)' can't be established.
ECDSA key fingerprint is SHA256:Vybt22mVXuNuB5unE++yowF7lgA/9/2bLSiO3qmYWBY.
Are you sure you want to continue connecting (yes/no)?

This is an onetime question. Answer (yes) to add the key to your know hosts file then you will see something like

Warning: Permanently added 'domian.xxx' (ECDSA) to the list of known hosts.

user@000.000.000.000's password:

SSH Examples

User name can be specified with the -l option

ssh -l user host

The default port for ssh is 22, to connect to a different port

ssh -p 5500 user@hostname.xxx

For connections issues pass the -v option to print debugging

ssh -v user@hotsname

Config File

The config file is very useful when you connect to a bunch of server, create the file in ~/.ssh/config

Host gemini
	HostNanme 000.000.000.000 (or domain name)
	User username
	Port 5500

Host html
	HostNanme 000.000.000.000 (or domain name)
	User username
	Port 5555

To connect to a host

ssh gemini
ssh html

Port Forwarding

To create a local port pass the -L option

ssh -L port:localip:port user@hostname -N

Example

ssh -L 3337:127.0.0.1:6379 user@domain.xxx -N

No password

Public Key Authentication

Home  Linux  Notes  Blog Spot