CodeRef
CodeRef
  • Software
    • VSCode
  • Midjourney_AI
    • Midjourney Cheat Sheet
  • aws
    • S3 Reference
    • Services
  • bash
    • .bashrc File Contents
    • CAN
    • _System Config File Locations
    • argument-length-limits
    • Conditionals
    • Data Structures
    • File Permissions
    • File Syncing
    • File System
    • Functions
    • General
    • Loops
    • My Functions
    • Networking
    • Number Operations
    • OpenVPN
    • Operators
    • Resource Management
    • Serial RS232
    • Spinning Wheel Animation
    • SSH
    • Text Operations
    • Environment Variables
  • cpp
    • ChatGPT | Pointers vs. References
    • arrays
    • Classes
    • Data Types / Structures
    • Enumerated Classes
    • Exception Handling
    • Function Objects
    • Functions
    • I/O
    • Loops
    • Macros
    • Namespaces
    • New Features
    • Pointers
    • Scope
    • Smart Pointers
    • Raw String Literals
    • Style Guide
    • Switch Case
    • Templating
    • How to Use tinyxml2
    • Useful Libraries
    • google-test
    • Conditionals
    • Rule of Three/Five
    • Optional Parameters
    • Keywords
    • Filesystem
    • Random
    • Casting
    • tools
  • git
    • Code Review Dependency Strategy
    • Git Bisect Guide
    • Git Reference
    • removing-cherry-picks
    • Useful Tools
    • Graphite Reference
  • js
    • functions
    • Javascript Reference
  • linux
    • Display
    • Dual Boot with Windows
    • File System
    • NVIDIA
    • Sending/Receiving TCP/UDP Messages in Ubuntu
    • dynamically_linked_binaries
  • markdown
    • Images
    • obsidian-reference
  • python
    • Classes
    • Exceptions
    • Functions
    • Operations
    • Python Reference
    • unittest_command-line-args
    • unittest_magicmock_GPT
    • unittest_mock
    • unittest_printing
    • unittest_subtest
    • useful-stuff
    • jupyter
    • poetry
  • ros
    • _ROS Cheat Sheet
    • Create New Workspace
    • Install ROS
    • Node Sample - Listener
    • Node Sample - Talker
    • Node Template
    • Setup
    • urdf
  • excel
    • excel-reference
  • windows
    • File System
    • WSL - Windows Subsystem for Linux
    • WSL
  • software_engineering
    • uncle_bob_lectures
      • Overview
      • Lesson 01 - Notes
  • web
    • Front End
    • Hugo
    • new_frontend_tools
  • sql
    • cheatsheet
Powered by GitBook
On this page
  1. bash

SSH

Make sure ssh-agent starts automatically and keys persist across reboots.

# Add these lines to ~/.bashrc
eval "$(ssh-agent -s)"
ssh-add -k ~/.ssh/*

# Check keys added to ssh-agent
ssh-add -l
ssh-add -L

SSH into a host machine:

# -i = pass in a private key (identity) file.
# IP = ip of the host machine
ssh -i ~/.ssh/id_rsa username@192.168.1.45
# Specify port
ssh <user>@<hostname> -p 8090

Kill a frozen SSH terminal:

# Key sequence = Enter, shift + ~, period

Copy file from remote to local machine desktop folder:

scp username@192.168.1.45:~/files/test.txt ./Desktop

Run bash commands on remote machine over SSH:

ssh username@192.168.1.45 "ls -la ~/files"
ssh username@192.168.1.45 "ls -la ~/files; cd /; ifconfig"	# Multiple commands.

Adding SSH keys:

# Start SSH agent. This wipes all existing keys from the agent.
eval "$(ssh-agent -s)"
# Add the key.
ssh-add ~/.ssh/id_ed25519
# List existing keys registered with the agent.
ssh-add -l

Generate Public SSH Key from Private Key:

ssh-keygen -y -f ~/.ssh/id_rsa > ~/.ssh/id_rsa.pub

Last updated 1 year ago