Skip to content

Instantly share code, notes, and snippets.

@duclos-cavalcanti
Last active April 3, 2023 01:07
Show Gist options
  • Save duclos-cavalcanti/340ba8964f017542b04331c9a4646b99 to your computer and use it in GitHub Desktop.
Save duclos-cavalcanti/340ba8964f017542b04331c9a4646b99 to your computer and use it in GitHub Desktop.
SSH cheat sheet

SSH cheat sheet

0. Basics

0.1 Commands

  • Check the IP address
sudo ifconfig
  • Connect
ssh -p <port> <username>@<ip_address>

0.2 Config

Host <shortcut to name>
    HostName <either IP adress or HostName>
    User <user>
    Port <port>

0.3 SSH File System

# sudo apt install sshfs
sudo pacman -S sshfs
sudo sshfs -o allow_other <user>@<hostname>:<path remote> <local mount>
sudo umount <local mount> # to unmount

# the ssh config can also short the need of typing user and hostname!

1. Ubuntu/Debian

1.1 Installation

sudo apt-get update
sudo apt install openssh-server

1.2 The SSH Daemon

systemctl status ssh        # evaluate the status of the sshd
systemctl enable ssh --now  # enable the daemon service
systemctl start ssh --now   # starts it

1.3 SSH Port

ss -ntlp | grep -i ssh

1.4 FirewallD

sudo apt install ufw
sudo ufw allow ssh
sudo ufw status

1.4 VirtualBox

On Host

  1. Machine -> Settings -> Network Settings -> Bridged Adapter

On Vbox

# find out connection name
nmcli con show
# with connection name=Wired connection 1 check ipv4 method is 'auto'
nmcli con show "Wired connection 1" | grep "ipv4.method"
# restart network
nmcli networking off
nmcli networking on
# should show the new configuration changes where enp0s8 takes up the Wifi router's IP Address
# look at inet
ip a

Example sshconfig for it:

Host vbox
    HostName 192.168.10.133
    User foo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment