buymeasoda RefDocs
  • Overview
  • General
    • Android
    • Apache
    • Fish
    • Git
    • Github
    • Gmail
    • Homebrew
    • iOS
    • iTerm
    • MacOS
    • MacPorts
    • Mamp
    • Media
    • Mercurial
    • MySQL
    • Node
    • npm
    • nvm
    • Obsidian
    • PHP
    • React Native
    • Rust
    • Server
    • Slack
    • Sourcegraph
    • Tools
    • Vim
    • VS Code
    • Yarn
  • Unix
    • Checksum and hash utilities
    • Command line history
    • Command line keyboard shortcuts
    • Compress files and folders
    • Crontab
    • Diff files and folders
    • Disk usage and file sizes
    • Find and search files
    • Firewall configuration
    • Help and manual pages
    • HostName and Local HostName for Mac OSX
    • Navigating the file system
    • Network, domains and routing
    • Run and manage background tasks
    • Secure FTP SFTP and Secure Copy SCP
    • Secure Shell SSH
    • Sync files and folders
    • System and process management
    • System and user information
    • Useful characters
    • Useful commands
    • User, file and group permissions
    • Working with cURL
    • Working with files and directories
    • Working with text
Powered by GitBook
On this page
  • Secure Shell SSH
  • SSH Config
  • SSH Access
  1. Unix

Secure Shell SSH

Secure Shell SSH

Connect as <user> to remote <host> on specified <port> If you do not specify a username it uses your current username

ssh -p <port> <user>@<host>

SSH Config

Location of SSH settings and host configuration

~/.ssh

If the SSH directory does not exist create it at ~/.ssh

mkdir ~/.ssh
chmod 700 ~/.ssh

If an SSH config file doesn't exist create it at ~/.ssh/config

cd ~/.ssh
touch config
chmod 600 config

Add details for a host entry

Host <nickname>
  HostName <server>
  User <username>
  Port <port>

Use SSH configuration

ssh <nickname>

Add SSH key passphrase to MacOS Keychain

ssh-add -K ~/.ssh/<key-file>

Note: If config file cannot be edited using sudo check the file is not locked via macOS Finder (File -> Get Info -> Locked)

SSH Access

Connect to remote machine using SSH public / private key instead of username and password.

On the remote machine, if there is no existing ~/.ssh directory or ~/.ssh/authorized_keys file, create one:

mkdir ~/.ssh && cd ~/.ssh
nano authorized_keys

Then past your public key into the file and save.

If an authorized_keys file exists, append your key to that file on a new line.

PreviousSecure FTP SFTP and Secure Copy SCPNextSync files and folders

Last updated 1 year ago