Skip to content

Instantly share code, notes, and snippets.

@evaporei
Created September 24, 2023 17:41
Show Gist options
  • Save evaporei/bd88ab0f0df2b321d4ffdd3a0cb63a15 to your computer and use it in GitHub Desktop.
Save evaporei/bd88ab0f0df2b321d4ffdd3a0cb63a15 to your computer and use it in GitHub Desktop.
ssh mac (host) into linux (remote) in the same network (eg: wifi)

Linux

  1. Get your local IP address
$ ip route
default via IP1 dev wlan0 proto dhcp src IP2 metric 600 
IP3/24 dev wlan0 proto kernel scope link src IP2 metric 600

Copy the second one (IP2), the first (ending with .1) is probably the router (if you connect to it you might see errors with dropbearssh).

  1. Make sure you have a ssh server running
$ sudo systemctl start sshd

Mac

  1. Generate a new ssh key, and preferably choose a passphrase
$ ssh-keygen -t rsa -b 4096 -f ~/.ssh/decide_a_key_name_here
  1. (Optional) Add an entry to your ~/.ssh/config to ease connecting to the server
Host ALIAS
  User USER
  Hostname REMOTE-IP
  IdentityFile ~/.ssh/the_key_name_you_ve_decided
  1. Copy the public key to the server
$ ssh-copy-id [remote-user]@[remote-ip] # or ssh-copy-id ALIAS
  1. To connect
$ ssh [remote-user]@[remote-ip] # or ssh ALIAS
@evaporei
Copy link
Author

Thanks @isinyaaa for the help 🙏
This tutorial wouldn't be possible without her 🐱

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment