SSH
generating keys, setting up config, basic and usefull commands
What's up folks! Markiplier here, I will show you how to work with SSH for different systems. I don't have any expirience with Apple software but it should handle the same as Linux I will mention if Windows needs special attention.
SSH stands for Secure Shell. It's used most commonly for connecting to servers/computers. It was a replacement for Telnet, which is plaintext, while SSH uses stronk encryption. The most common SSH is OpenBSD's OpenSSH, but there are alternatives like Dropbear.
Everything written inside <brackets should be replaced, with them included> I will write $ if user can write a command and # if you need elevated privileges like with sudo/doas/root/admin
if you want to connect to a server, write in your shell
$ ssh <user>@<ip or domain>
There flags that you should know
| flag | what is it for |
|---|---|
-p | for port |
-i <your private key | include key |
-v | verbose, if you need more info on what is happening during connection and breaking it |
-R <server port>:localhost:<client port> | port forwarding from server to client |
-L <client port>:localhost:<server port> | port forwarding from client to server |
-N | do not execute any commands, useful for port forwarding |
-f | run ssh in background after auth, also useful for port forwarding |
-P | for port in scp |
How to simplify connections
You can create config file in your .ssh folder, it's located in your /home/<user> directory, or /root or in C:\Users\<user> in case of Windows
- config
Host <your chosen name> Hostname <your IP/domain> User <your username> IdentityFile <path to private SSH key> Port <port opened for SSH>
You have way more settings to work with so look them up and have fun! Flags mentioned above can be also set in ~/.ssh/config (with appropriate keywords)
How does my machine become a server?
In case of Linux and Unix like systems, you should start sshd daemon, like
# systemctl enable –now sshd
It's best to edit /etc/ssh/sshd_config as sudo/root and change the settings you want.
In general it's best to disable passwords and root login. Just uncomment the line by deleting “#” and write yes/no in appropriate place
