Coolest Guides on the Planet

coolest guides on the planet

Coolest Guides On The Planet

  • Home
  • macOS
  • WebDev
  • All Posts
  • Contact

Secure Remote SSH Connection with no passwords OSX 10.7 and Linux

June 27, 2011 2 Comments

How to generate public and private keys for SSH on Mac OS X 10.7 and then share that public key no so password is prompted for a secure connection with a remote computer. OSX 10.9 Mavericks SSH Connection guide is here.

ssh-private-public-keys

ssh-private-public-keys

First thing that you need to do is to create a directory that will store your SSH keys and then generate a public and private key for your account, launch the Terminal and type:

<–Puts you in your home directory–>

username@[~]: cd

<– Creates .ssh directory and moves you into it–>

username@[~]: mkdir .ssh ; cd .ssh

<–Creates your private and public key, the blank quotes gives the private key no password, so allowing for automatic logins–>

username@[~]: ssh-keygen -b 1024 -t rsa -f id_rsa -P ""

<–Change into and view the contents of your .ssh directory–>

username@[~]: cd .ssh ; ls -la

-r–r–r–   1 username  staff   1.4K Jun  1 11:35 authorized_keys2 <–List of authorized keys–>
-rw——-   1 username  staff   887B Jun  1 11:35 id_rsa <–Your private key–>
-rw-r–r–   1 username  staff   239B Jun  1 11:35 id_rsa.pub <–Your public key–>

Thats your keys created, don’t give out the private one always keep that one only on your local machine.

You can create automatic logins by adding the contents of your public key to a corresponding destinations authorized key file. In OSX 10.7 its called authorize_keys2 on other OS’es it may be called something similar but will still be in the .ssh directory.

To see and copy your public key:

<–Displays your public SSH key, which you can copy and add to another remote computer –>

username@[~/.ssh]: cat id_rsa.pub
ssh-rsa  AAAAB3NzaC1yc2EAAAABIwAAAIEA2CtcmYRmQJX04pZnrTPrU68BZMk9YlbI6CUcFUp
RVw29p V7mxW16wd/q9z7n+xytqdp4wsAc/7+24ZVikMhhRetEGr3LSBz5gm9980oTPEy61+pDP2y
jafShe5xcszIUnQ rN1ohCuF7Y/a/TG6G6gaJGcLexUiwfTRtCAbpuzfU= [email protected]

On the remote computer if needed change the permssions on the authorized_keys file to write to add new new public key, on a new line paste in your public key, and change it back to read only after for security:

-rw——-   1 username  staff   1.4K Jun  1 11:35 authorized_keys

Paste the entire id_rsa.pub content with vi or nano into the authorized_keys file.

If the remote host does not have an “authorized_keys” file simply create one and after the public key is pasted in don’t forget to takeaway write permissions.

So now when you connect via SSH no password is prompted as the remote computer has your public key which is in turn only decrypted by your private key held in your local .ssh/ directory. If you want the communications to be bilateral then repeat the process in the opposite order between the two.

Now the two computers can securely connect with no password prompting, making it ideal to script between the two for file copies or back ups.

Cats: macOS, Open Source Tags: keys, OSX, private, public, remote, rsa, ssh

Tags

3gs 10.6 apache backup baseband boot clean urls cpanel css curl custom database drupal el capitan git Google image instadmg ios iphone jailbreak keys lion mac macos mojave macos sierra menu mysql OSX panda php phpmyadmin private public redirect redsn0w remote rsa SEO shell ssh terminal unstoppables upgrade urls

Donate a Beer to the Coolest Guides

Get Beaver Builder Now!

Discuss

3gs 10.6 apache backup baseband boot clean urls cpanel css curl custom database drupal el capitan git Google image instadmg ios iphone jailbreak keys lion mac macos mojave macos sierra menu mysql OSX panda php phpmyadmin private public redirect redsn0w remote rsa SEO shell ssh terminal unstoppables upgrade urls
Get DesktopServer

Lynda

Lynda.com Online Training Videos

TreeHouse

smlinks

Learn WordPress
osx-modify-shell-path

How to Add to the Shell Path in macOS Big Sur and Catalina using Terminal

October 19, 2019

virtual-hosts osx 10.10 yosemite

Set up Virtual Hosts on macOS Catalina 10.15 in Apache

October 19, 2019

Installing Homebrew on macOS Catalina 10.15, Package Manager for Linux Apps

October 18, 2019

Where is the bash shell in macos Catalina?

October 12, 2019

Refine your search

  • All
  • Modules
  • Themes
  • Documentation
  • Forums & Issues
  • Groups

RSS ars technica

  • Apple details the end of Intel Mac support and a phaseout for Rosetta 2
  • Apple tiptoes with modest AI updates while rivals race ahead
  • Apple drops support for just three iPhone and iPad models from iOS and iPadOS 26
  • macOS Tahoe signals that the end is near for Intel Macs, dumping all but four models
  • With visionOS 26, Apple begins to zero-in on what the Vision Pro is actually used for

RSS mac surfer

Donate

Copyright © 2025· Neil Gee - All Rights Reserved - Hosted by Runcloud

Copyright © 2025 · gee on Genesis Framework · WordPress · Log in