Hot answers tagged

1264 votes
Accepted

How can I permanently add my SSH private key to Keychain so it is automatically available to ssh?

It is not possible to add private key to Keychain, but you can store passphrase for private key in Keychain. On OSX, the native ssh-add command has a special argument to save the private key's ...
trisweb's user avatar
  • 12.8k
260 votes
Accepted

macOS Sierra doesn’t seem to remember SSH keys between reboots

As of macOS Sierra 10.12.2 Apple added an ssh_config option called UseKeychain which allows a 'proper' resolution to the problem. Add the following to your ~/.ssh/config file: Host * AddKeysToAgent ...
mluisbrown's user avatar
  • 3,892
124 votes

macOS Sierra doesn’t seem to remember SSH keys between reboots

I had this issue as well when attempting to deploy some code using Capistrano. Very frustrating. Here are two methods I know of to deal with this issue. Method 1: Add all known keys to the SSH agent. ...
Giacomo1968's user avatar
  • 5,523
93 votes
Accepted

How to SSH in one line

You should be using SSH keys to authenticate with rather than putting your password on the command line as it's extremely insecure. The way this works is once you have your SSH keys set up, all you ...
Allan's user avatar
  • 97.6k
55 votes

How can I prevent an SSH session from hanging in OS X Terminal?

You can: Configure your system, system-wide, for all connections By editing: /etc/ssh/ssh_config And add the line: ServerAliveInterval 10 Or, per-server ~/.ssh/config Host keepsdroppingme.com ...
Aleksandar Pavić's user avatar
54 votes

Tab completion for hosts defined in ~/.ssh/config doesn't work anymore on Yosemite

You can enable bash shell completion by installing bash-completion via brew: brew install bash-completion Then add the following to your ~/.bash_profile: if [ -f $(brew --prefix)/etc/...
Danny Armstrong's user avatar
53 votes

How can I permanently add my SSH private key to Keychain so it is automatically available to ssh?

I had a similar problem, in that I was being asked every time for my pub-key passphrase. Per suggestion of user "trisweb" above, I turned on these options to ~/.ssh/config: Host * UseKeychain yes ...
user2688272's user avatar
36 votes

How can I permanently add my SSH private key to Keychain so it is automatically available to ssh?

To all where the above did not work, my issue appears to have been because I was duplicating the UseKeychain yes & AddKeysToAgent yes in all ssh key profiles / shortcuts. I updated my ~/.ssh/...
Andrew's user avatar
  • 471
33 votes
Accepted

In terminal, scrolling prints weird characters

To fix this, just run the reset command. It will reinitialize the current terminal.
Marius's user avatar
  • 669
31 votes
Accepted

openssh hangs at "rekey after 134217728 blocks"

The issue is ssh is waiting for a connection to your ssh-agent. You can test this by running SSH_AUTH_SOCK= ssh [email protected]. If this is indeed the issue (as it was for me), then you probably have ...
TH.'s user avatar
  • 425
29 votes

Cannot change ssh port on High Sierra

Has Apple locked this file [/System/Library/LaunchDaemons/ssh.plist] down definitively? Yes, they have, you need to disable SIP (System Integrity Protection), but note that editing ssh.plist is not ...
jaume's user avatar
  • 14.9k
28 votes
Accepted

macOS 10.12 Sierra will not forget my ssh keyfile passphrase

To disable storing passphrase in keychain you should add following lines to ~/.ssh/config file: Host * UseKeyChain no If you already have passphrase stored in keychain you can delete it using ...
mbamac's user avatar
  • 416
25 votes
Accepted

Disable StrictHostKeyChecking in ssh

To disable strict host checking on OS X for the current user, create or edit ~/.ssh/config and add the following lines: Host [IP Address] StrictHostKeyChecking no UserKnownHostsFile=/dev/null ...
klanomath's user avatar
  • 65.9k
24 votes

macOS Sierra doesn’t seem to remember SSH keys between reboots

As explained here, this is the recommended method since macOS 10.12.2: Add the following lines to your ~/.ssh/config file: Host * UseKeychain yes AddKeysToAgent yes Any key you add to the ...
Ricardo Sanchez-Saez's user avatar
23 votes
Accepted

Can Touch ID unlock a personal SSH key?

Update: One option is add your private SSH key to macOS Keychain, then use TouchID for Keychain authentication. You will want to use ssh-add -K ~/.ssh/[your-private-key] -- however on macOS 10.12 ...
JeremyDouglass's user avatar
22 votes
Accepted

How to use SSH keys and disable password authentication

I was editing the wrong configuration file! Instead of /etc/ssh_config, I edited private/etc/sshd_config. I think this probably would have also worked if I edited /etc/sshd_config as per the updated ...
beznez's user avatar
  • 519
22 votes

How to SSH in one line

There are several possibilities. Your example will obviously not work, but you can achieve something similar using sshpass utility: sshpass -p password ssh host@IP Note, this is not recommended ...
Jakuje's user avatar
  • 1,558
22 votes
Accepted

Tilde character in password interferes with SSH login

From man ssh -e escape_char Sets the escape character for sessions with a pty (default: `~' ) . The escape character is only recognized at the beginning of a line. The escape character followed ...
nohillside's user avatar
  • 97.2k
21 votes

How can I permanently add my SSH private key to Keychain so it is automatically available to ssh?

Also, in macOS Sierra and High Sierra (don't know about previous versions), running ssh-add -A will get the agent to load all keys whose passphrases are stored on Keychain... So very handy Note that ...
JJarava's user avatar
  • 1,246
21 votes
Accepted

OS X : Terminal command to turn ON/OFF SSH server

You can stop the ssh service by typing the following: $ sudo launchctl unload /System/Library/LaunchDaemons/ssh.plist To start it again, use this: $ sudo launchctl load -w /System/Library/...
jherran's user avatar
  • 13.2k
20 votes

macOS 10.12 Sierra will not forget my ssh keyfile passphrase

Thanks to Clive, I have a better understanding of this new 'feature'. When you type in your passphrase Sierra adds it to your Keychain but not to the ssh-agent. If your identity isn't in ssh-agent ...
Gene Frenkler's user avatar
19 votes

How do I create user accounts from the Terminal in Mac OS X 10.11?

If you are here and your system is running anything from 10.10 and newer, the sysadminctl command is your best friend. It does a lot of magic that DSCL can't do. Here's the output for sysadminctl: ...
ub3rdud3's user avatar
  • 191
19 votes
Accepted

Recover SSH private key passphrase from keychain

Open Keychain Access and enable the option View > Show Invisible Items. Than you must search for id_rsa or ‘ssh’.
Approach's user avatar
  • 306
19 votes
Accepted

Can't enable SSH on Catalina - System Preferences keeps saying "Remote Login starting..."

The problem can be solved by manually adding the relevant launch daemon yourself via the Terminal, with the following command: sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist
Glorfindel's user avatar
  • 4,004
18 votes

Disable ssh password authentication on High Sierra

To prevent authentication without a public key, search for each of these in /etc/ssh/sshd_config, uncomment them, and set them to 'no': PasswordAuthentication no ChallengeResponseAuthentication no ...
kas's user avatar
  • 291
17 votes

Password dialog appears when SSH private key permissions are set to 0600

For macOS 10.12 Sierra ssh-add -K needs to be run after every reboot. To avoid this create ~/.ssh/config with this content. Host * AddKeysToAgent yes UseKeychain yes IdentityFile ~/.ssh/...
orkoden's user avatar
  • 1,112
17 votes
Accepted

Unable to unlock login keychain on sierra in ssh

Your login keychain doesn't appear to be in the search list, i.e. when you checked it, it just shows the System keychain twice. No login keychain: (~)$ security list-keychains "/Library/Keychains/...
Stephen Quan's user avatar
17 votes

Adding SSH private key gives error that 0644 permissions are too open

The error message is displayed because the file permission are set such that it is readable by other users apart from the logged-in user. To overcome the error message, you will need to change the ...
Nimesh Neema's user avatar
  • 50.7k
16 votes

What's a good SSH tunneling client for OS X?

Core Tunnel baked by Codinn is a tunnel manager that intuitive and easy to use: Support local, remote and dynamic port forwarding Compatible with OpenSSH Integrated with macOS Keychain Automatic ...
Yang.Y's user avatar
  • 309
16 votes

macOS Sierra doesn’t seem to remember SSH keys between reboots

I've written a short post about this topic that might help you. A solution is calling ssh-add -A command on every startup. Just add .plist file with the following content to the path ~/Library/...
Jirsbek's user avatar
  • 161

Only top scored, non community-wiki answers of a minimum length are eligible