From owner-freebsd-questions@FreeBSD.ORG Mon Aug 23 00:46:17 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C6D9416A4CE for ; Mon, 23 Aug 2004 00:46:17 +0000 (GMT) Received: from kane.otenet.gr (kane.otenet.gr [195.170.0.27]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7F1A043D2D for ; Mon, 23 Aug 2004 00:46:14 +0000 (GMT) (envelope-from keramida@ceid.upatras.gr) Received: from gothmog.gr (patr530-b181.otenet.gr [212.205.244.189]) i7N0kAg1023678; Mon, 23 Aug 2004 03:46:12 +0300 Received: from gothmog.gr (gothmog [127.0.0.1]) by gothmog.gr (8.13.1/8.13.1) with ESMTP id i7N0in7s037503; Mon, 23 Aug 2004 03:44:49 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Received: (from giorgos@localhost) by gothmog.gr (8.13.1/8.13.1/Submit) id i7N0imZs037496; Mon, 23 Aug 2004 03:44:48 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Date: Mon, 23 Aug 2004 03:44:48 +0300 From: Giorgos Keramidas To: Gary Kline Message-ID: <20040823004448.GA31125@gothmog.gr> References: <20040822224148.GA60895@thought.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040822224148.GA60895@thought.org> Phone: +30-2610-312145 Mobile: +30-6944-116520 cc: freebsd-questions@freebsd.org Subject: Re: How can I tell if I'm ssh'd into a host? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2004 00:46:17 -0000 On 2004-08-22 15:41, Gary Kline wrote: > > This is a strange one. On different hosts in my ~/.zlogin, I test for > `hostname` = HOST.thought.org > > If true, I do certain things such as set xhost FOO and xmodmap > ~/.xmodmaprc... I've noticed that with my 5-CURRENT on my laptop, > I get complains from xhost and naturally, xmodmap. > > Is there a way of asking where I am on the console/KVM, or remote and > ssh'd? Sorry if I''m not explaining this well. --I didn't notice > these complains when I had 4.10 on my laptop. Aside from having > .zlogin prompt: "Are you ssh'd in? [y/[n]] " I'm drawing a blank. $ env | grep SSH SSH_CLIENT=212.205.244.189 64903 22 SSH_TTY=/dev/pts/0 SSH_CONNECTION=212.205.244.189 64903 62.1.205.36 22 If SSH_CONNECTION is set, you can bet you're ssh'ed into a host. As a small extra tip, I use this as a local hack in the .bashrc file of the root user in my company's servers, to add customizations that apply only when an incoming ssh connection from my personal workstation is detected: if [ X$( echo ${SSH_CONNECTION} | awk '{print $1}' ) = X"10.0.0.X" ]; then # Customizations SSH connections originating at my workstation. # - Giorgos Keramidas source ~/.bashrc.keramida fi