Skip to content

Latest commit

 

History

History
87 lines (63 loc) · 1.45 KB

ssh.md

File metadata and controls

87 lines (63 loc) · 1.45 KB

SSH

SSH Commands

  • ssh-copy-id user@hostname
    Login without password

  • ssh-keygen -R hostname
    Remove entries in ~/.ssh/known_hosts

SSH Config

Connect via ssh alias by setting the alias in ~/.ssh/config

Basic

ssh [email protected] -p 4000

Host alias
  HostName 10.10.10.10
  Port 4000
  User user

Proxy Server

ssh -J [email protected]:4000 [email protected]

Host alias
  HostName 192.168.0.10
  ProxyJump 10.10.10.10:4000
  User user

Forward Port

ssh -L 6000:localhost:5901 [email protected] -p 4000

Host alias
  HostName 10.10.10.10
  Port 4000
  LocalForward 6000 localhost:5901
  User user

Local Command

ssh -L 6000:localhost:5901 [email protected] -p 4000 -o 'LocalCommand=echo "Connect localhost:6000'

Host alias
  HostName 10.10.10.10
  Port 4000
  LocalForward 6000 localhost:5901
  LocalCommand echo "Connect localhost:6000"
  PermitLocalCommand yes  # or set in General Rules section
  User user

Remote Command

ssh [email protected] -p 4000 -t -o 'RemoteCommand=cd folder/ && bash -l'

Host alias
  HostName 10.10.10.10
  Port 4000
  RemoteCommand cd folder/ && bash -l
  RequestTTY force
  User user

General Rules

Host *
  AddKeysToAgent yes     # MacOS only
  UseKeychain yes        # MacOS only
  ServerAliveInterval 60  # For not disconnecting
  ServerAliveCountMax 10  # For not disconnecting
  PermitLocalCommand yes