LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 04-15-2011, 08:43 AM   #1
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,647
Blog Entries: 31

Rep: Reputation: 175Reputation: 175
ssh-agent for multiple terminals


I use many terminal windows and/or virtual consoles on Linux, often as many as 60 of them. I'm now trying to start using ssh-agent to keep my SSH keys encrypted. What I am finding is that using ssh-agent on each creates multiple instances. That doesn't work very well. It seems what I need to do is create one instance and get all the information shared into the environment space of each terminal/console instance. Before I go off to design something to do that, I'm just wondering if it has been done, already.
 
Old 04-15-2011, 09:17 AM   #2
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,647

Original Poster
Blog Entries: 31

Rep: Reputation: 175Reputation: 175
My first thought is to start the ssh-agent from a script which captures the named socket path and makes a fixed symlink pointing to it. Of course, this defeats obscurity of the path, but is that real security (answer: no). Another symlink is made to store the PID. Then I would have a bash alias or command function in the login shell for each terminal that can refresh the environment variables from those known symlinks. I would run that in each login shell. Alternatively, an ssh wrapper script would pick up those values to pass directly to the real ssh program. What security risks might this be creating?
 
Old 04-15-2011, 10:43 AM   #3
nomb
Member
 
Registered: Jan 2006
Distribution: Debian Testing
Posts: 675

Rep: Reputation: 58
I'm pretty sure you can have ssh-agent write it's socket path out to a file and then just source it.
 
Old 04-15-2011, 10:47 AM   #4
nomb
Member
 
Registered: Jan 2006
Distribution: Debian Testing
Posts: 675

Rep: Reputation: 58
http://superuser.com/questions/14104...login-sessions
 
Old 04-15-2011, 12:38 PM   #5
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,647

Original Poster
Blog Entries: 31

Rep: Reputation: 175Reputation: 175
The first security issue I found was one of my own making. I had "ForwardAgent yes" in my .ssh/config files. That's fixed, now. That would not work well when accessing servers where other admins have root access. It will have to be specific to fully trusted machines.
 
Old 04-15-2011, 12:46 PM   #6
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,647

Original Poster
Blog Entries: 31

Rep: Reputation: 175Reputation: 175
Here's what I started dabbling with on my own called "start-ssh-agent":
Code:
#!/bin/bash

cd || exit 1

if [[ -n "${kill}" || -n "${KILL}" ]] ; then
	if [[ -L .ssh_agent_pid ]] ; then
		ssh_agent_pid=$( exec readlink .ssh_agent_pid )
		kill -TERM "${ssh_agent_pid}" 2>/dev/null
		sleep 1
		kill -KILL "${ssh_agent_pid}" 2>/dev/null
	fi
else
	if [[ -L .ssh_agent_pid ]] ; then
		ssh_agent_pid=$( exec readlink .ssh_agent_pid )
		echo "SSH agent already active at process ID ${ssh_agent_pid}"
		echo "kill it or run:  kill=yes start-ssh-agent" "$@"
		exit 1
	fi
fi

if [[ -L .ssh_auth_sock ]] ; then
	ssh_auth_sock=$( exec readlink .ssh_auth_sock )
	rm -fv "${ssh_auth_sock}"
	rm -f .ssh_auth_sock
fi

eval $( exec ssh-agent -s ) 1>/dev/null

ln -fns "${SSH_AUTH_SOCK}" .ssh_auth_sock
ln -fns "${SSH_AGENT_PID}" .ssh_agent_pid

ls -dGl .ssh_auth_sock
ls -dGl .ssh_agent_pid

exit 0
Now I need to either set up a bash alias/function to set these variables in its environment, or make an ssh wrapper that picks them up and sets them in that context. Since I already have an ssh wrapper for other reasons, I'll favor that for my first attempt.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] ssh-agent -> The agent has no identities. windstory Linux - Security 2 11-19-2008 06:45 PM
ssh-agent, ssh-add and ssh-keygen AND CVS raylpc Linux - General 2 11-19-2008 02:50 AM
need help with no password ssh and ssh-agent hedpe Linux - Networking 3 02-08-2007 08:49 PM
ssh-agent/ssh-add question mega Slackware 2 01-26-2005 03:09 AM
Terminals - spying on local terminals with ssh BeatRyder Linux - Software 5 10-21-2004 01:47 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 06:01 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration