can you decipher this script ?

ssh-add -t 30 >/dev/null 2>&1
LOGNAME=`whoami`
cp $HOME/.ssh/known_hosts $HOME/.ssh/known_hosts.org
grep -v localhost $HOME/.ssh/known_hosts.org > $HOME/.ssh/known_hosts

ssh -1 -f -l $LOGNAME -o "ForwardX11 yes" -o "StrictHostKeyChecking no" -L 6003:195.244.210.107:2222 ext-proxy-2 sleep 5 >/dev/null 2>&1
xterm -title GIBFDX -e ssh -1 -q -o "StrictHostKeyChecking no" -l fujitsu -p 6003 -L 8080:accessmngr.gibtelecom.lan:8080 localhost &

can anyone decipher the above script word for word if possible I know what certain bits do but it would be great if an expert could explain, sorry im new to scripting and will also check the newbie threads.

thanks in advance

Please mention what version of SuSE you have.
Please edit post #1 if I have guessed the line breaks incorrectly. The line containing "sleep 5" still looks unlikely unless it is just testing the ssh connection.

Sorry but I cannot help with the actual query but I'm trying to get the post clearer for other posters.

1 Like

10.0 (i586)

It's just a script to add a new 'user account' to an ssh infrastructure, and seems to rely on using the known_hosts config files (there's one on each side) as the 'authentication'.

Just lookup each command and it's options with 'man',
and read up on how ssh works. Easy stuff :wink:

The 'remote' 'sleep 5' command allows you to run/request a 'reverse' connection,
a.k.a. 'bounce' off the remote server.
Similar to what you would do with a reverse VNC connection, but the 'listening' side only runs for 5 seconds..

2 Likes

@unisoftdesign
I know nothing about SuSE Linux. This could change overnight if I get interested.

What is the reason for the script lines which remove "localhost" from the file pointed to by $HOME/.ssh/known_hosts.org ? Where does this file come from?

Does SuSE Linux bash Shell not set $LOGNAME ? It's a standard Environment Variable in unix.

@llcooljatt
Please post the bits you understand. Saves time for the other posters.

1 Like

Same here, I just focus on the (generic) SSH and grep syntax. Who knows what flavour of SSH the OP is on?

No line is being removed. A line is grepped out and copied onto the other system. The known_hosts files are part of an existing SSH infrastructure.

Good point, maybe his version of Suse is weird/proprietary/commercialised, or a predecessor has been cutting and pasting too much? Document and annotate, people!

1 Like

the first bit having read it is trying to add known_hosts to known_hosts.org i presume then looks for a comparison and looks for non-matching lines but what does it do with them?

I think im getting confused how it all ties in.

I understand most of the options listed apart from -q ?

also what is
"StrictHostKeyChecking no"
"ForwardX11 yes"

also the line:
-l fujitsu -p 6003 -L 8080:accessmngr.gibtelecom.lan:8080 localhost &

the -p 6003 is the local linux port? mapping to blind host address/port ?

and $HOME is the users home directory?

Just had tea and is thinking...

---------- Post updated at 12:57 PM ---------- Previous update was at 12:04 PM ----------

It's not really comparing, the grep command is used to stream/spool the whole known_hosts file, minus any lines that have "localhost" in them. My SSH config files never have that in there, so I can't really help any further on that.

So are we. Some known_hosts file has appeared on the user's account which has lines in it for "localhost", which get pruned out.

Check the local man pages. My local system does not have a -q or -Q option.

Normally, yes. We have no idea if the system you are working on has black voodoo on it :wink: