Tag Info

Hot answers tagged

25

1) In your SSH rc script (~/.ssh/rc) you will set up a symbolic link from a canonical location to the "current" SSH_AUTH_SOCK. Here's how I do it in bash (content of ~/.ssh/rc): #!/bin/bash if test "$SSH_AUTH_SOCK" ; then ln -sf $SSH_AUTH_SOCK ~/.ssh/ssh_auth_sock fi (and make sure to chmod 755 ~/.ssh/rc). The "test" is just to prevent an error from ...


20

ssh -A [user@]remotehost I think this might be what you're looking for. Use the -A switch when running ssh forward your ssh-agent. Here's a usecase: I have a remote server that has some git repos on it with a remote pointing to github. Without an ssh-agent running in a screen session, I have to enter the passphrase for my key in order to do a "git pull ...


15

Ssh agent forwarding must be allowed on the client (ForwardAgent option in ~/.ssh/config) and on the server (AllowAgentForwarding option in sshd_config). Chances are that your machines have different default settings for one or both of these options. If you're going A->B->C, forwarding is not necessary on the B->C step (unless you're then going to go C->D ...


14

You could cheat and put something like alias ssh='ssh-add -l || ssh-add && ssh' on your .bashrc / .profile. This first runs ssh-add -l, which can return 0 (there are keys on agent), 1 (no keys) or 2 (no agent running); if it returns 0, ssh will run; if 1, ssh-add will run and then ssh; if 2, ssh-add will fail and ssh won't be run. Replace the ...


14

On OS X Lion, ssh-agent is configured to start at boot by default. And ssh-agent will always load your default keys (~/.ssh/id_rsa and ~/.ssh/id_dsa). If you have multiple ssh keys (I have one for each client/project) and want ssh-agent to remember them across restarts: ssh-add -K ~/.ssh/your-other-key I give mine an expiration as well, although honestly, ...


13

SSH keys are just plain RSA, DSA, or ECDSA asymmetric key pairs. Such a keypair generated by OpenSSH can already be used by OpenSSL and most other programs. (The .pub file output by ssh-keygen is in OpenSSH-specific format, but that is irrelevant since the "private" file already contains both private and public keys.) Other SSH software may have their own ...


12

While you already have the right answer by @Gilles above, I wanted to point out that AllowAgentForwarding is only supported in OpenSSH 5.1 onwards. OpenSSH servers before 5.1, from what I have seen in my RHEL 4u5 box, allow agent forwarding by default. So if your server is older than 5.1 and agent forwarding is not working, the problem is likely in the ssh ...


10

I might as well throw my own variation into the mix: function sshagent_findsockets { find /tmp -uid $(id -u) -type s -name agent.\* 2>/dev/null } function sshagent_testsocket { if [ ! -x "$(which ssh-add)" ] ; then echo "ssh-add is not available; agent testing aborted" return 1 fi if [ X"$1" != X ] ; then export ...


10

SSH is only capable of forwarding tcp connections within the tunnel. You can, however, use a program like socat to relay the unix socket over TCP, with something like that (you will need socat both on the client and the server hosts): # Get the path of gpg-agent socket: GPG_SOCK=$(echo "$GPG_AGENT_INFO" | cut -d: -f1) # Forward some local tcp socket to ...


10

ssh-agent is the piece that you want to get working, as it does exactly what you're asking about. The agent runs as a daemon, and when you "add" a private key to it, it remembers that key and automatically provides it to the remote sshd during the initial connection. (ssh-add is simply the command you run to manually add a private key to ssh-agent). In OS ...


9

During the process of resolving the "problem", I've googled some related topics and write down some notes about how ssh-agent, ssh-add, keychain, KeyChain Access.app work. It finally turns out that this issue is not a problem at all, instead the issue is all about me, and so called ssh-login-without-asking-passphrase-every-time works perfectly on Mac out of ...


9

Here's a pretty nice one that works in Cygwin as well: SSH_ENV=$HOME/.ssh/environment function start_agent { echo "Initialising new SSH agent..." /usr/bin/ssh-agent | sed 's/^echo/#echo/' > ${SSH_ENV} echo succeeded chmod 600 ${SSH_ENV} . ${SSH_ENV} > /dev/null /usr/bin/ssh-add; } # Source SSH settings, if applicable ...


8

You can now use FileZilla -> Preferences -> Connection -> SFTP which will allow you to import your private key.


8

Your SSH keys should not get automatically added to the agent just because you SSH'ed to a server... Run ssh-add -l to list the agent's keys, ssh-add -D to clean out all keys.


8

An elegant solution, picked up from dagit.o: Create ~/.ssh/rc #!/bin/bash if [ -S "$SSH_AUTH_SOCK" ]; then ln -sf $SSH_AUTH_SOCK ~/.ssh/ssh_auth_sock fi Add to ~/.tmux.conf set -g update-environment "DISPLAY SSH_ASKPASS SSH_AGENT_PID SSH_CONNECTION WINDOWID XAUTHORITY" set-environment -g 'SSH_AUTH_SOCK' ~/.ssh/ssh_auth_sock


7

Each time you ssh into bastion01, a different socket is opened to handle the key forwarding. You can see the filename in the environment variable SSH_AUTH_SOCK. When you start tmux, the value of that environment variable is included in tmux's global environment, which is inherited by any shells started in that session. Now, when you reconnect to bastion01 ...


7

Try using keychain, its made for that. http://www.gentoo.org/doc/en/keychain-guide.xml


6

When you open a second connection to your VM, it will use a different SSH_AUTH_SOCK environment variable, but tmux and the processes under it will only know the old value. When you attach to an existing session, tmux can tell the master process to update some environment variables. SSH_AUTH_SOCK is already in the list, but you can add custom ones by ...


6

Depending on which key you need... Private key – to log in from a Unix system into another Unix You must first convert the key, using PuTTYgen, from PuTTY format to one OpenSSH can use. In the Windows version of PuTTYgen, use the Conversions → Export OpenSSH key menu item; in the Linux version, puttygen mykey.ppk -O private-openssh -o mykey. Only ...


6

You can use the public part of a key to to specify which private key you want to use from the forwarded agent. This requires creating an extra file (the public part of the key) on any “intermediate” machines (machines to which you forward your local ssh-agent). Arrange for the intermediate machine to have a copy of the public part of the desired key in a ...


6

It looks like it might be a bug. I am having similar behavoir in Ubuntu 10.10. A google search found a bug report for Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=472477 To remove the extra keys I had showing, I just moved them out of the ~/.ssh directory.


6

How about simplifying it a bit? agent_running() { [ "$SSH_AUTH_SOCK" ] && { ssh-add -l >/dev/null 2>&1 || [ $? -eq 1 ]; } } env=~/.ssh/agent.env if ! agent_running && [ -s "$env" ]; then . "$env" >/dev/null fi if ! agent_running; then ssh-agent >"$env" . "$env" >/dev/null ssh-add fi unset env


5

GNOME stores your SSH key passphrases in GNOME Keyring, which (the login keyring) is unlocked with your login password by pam_gnome_keyring: #%PAM-1.0 auth ... auth ... auth optional pam_gnome_keyring.so session ... session ... session optional pam_gnome_keyring.so auto_start However, your ...


5

The Puttygen window contains a text area with the public key in the format expected by SSH. Copy it, and add it to the file ~/.ssh/authorized_keys on the server on its own separate line. Make sure the file and the directory are not readable/writeable by group and others, i.e. run chmod go-rwx ~/.ssh ~/.ssh/authorized_keys. Then the server will accept your ...


5

Until auto-call-ssh-add is supported by ssh, I added this in my .bashrc, based on Kovensky proposal: ssh-add -l >/dev/null || alias ssh='ssh-add -l >/dev/null || ssh-add && unalias ssh; ssh' The alias is created only if the identity is not added, and the alias destroys itself once run. This way the regular ssh command is used after the ...


5

Found it elsewhere. I had to do this: ssh-add ~/.ssh/id_rsa


4

I think this works as a simplification of @sandip-bhattacharya's answer. Put this in your ~/.bashrc file, and run the export command in any currently running screen sessions. if [ -S "$SSH_AUTH_SOCK" ] && [ ! -h "$SSH_AUTH_SOCK" ]; then ln -sf "$SSH_AUTH_SOCK" ~/.ssh/ssh_auth_sock fi export SSH_AUTH_SOCK=~/.ssh/ssh_auth_sock That reads "if ...


4

Simply seeing that ssh-agent is running is insufficient. Look to see if the key you want is present ssh-add -L Have you verified that this key works from some other host? What does ssh-add -L print on that system? You can also run GIT_TRACE=1 git ls-remote ... and it will print the ssh command it runs. You can manually run the ssh command and get that ...


4

In your .tmux.conf configuration file, add this line: set -g update-environment "SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID SSH_CONNECTION" This causes these environment variables to be copied from your main shell to any shells opened within tmux, which then allows ssh-agent to work properly within those tmux shells.



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