Sponsored Content
Special Forums IP Networking How to extract NIC and other info ,given Ip Post 302229306 by buffoonix on Tuesday 26th of August 2008 05:39:51 PM
Old 08-26-2008
Executing commands remotely via SSH isn't that much different from doing the same via rsh/remsh, except for the lack of the cryptographic tunnel, so to speak.
Usually one would create a pair of RSA keys by ssh's ssh-keygen command,
then distribute it to all remote hosts where one wishes to remotely execute the commands.
On the host from where you schedule your checks create a key pair.
Log in as a non-root user.
If in your $HOME there is no subdir .ssh present then it would be the easiest way to create the necessary structure by connecting to any remote SSH server. This doesn't have to be a real login. You would only confirm with yes when you are asked by your ssh client if it should add the new host key from the remote host. Then interrupt by pressing ^C.
This only serves the purpose to have the .ssh subdir and known_hosts file in it automatically created with the correct ownership and permission bits by your SSH client
because per default any SSH server runs with StrictModes enabled and thus is very picky about correct perms.
So run $ ssh some_host, confirm with yes, and abort when being asked for a password.
Now you can create your RSA key pair by issuing
Code:
 $ ssh-keygen -t rsa -b 1024 -N "" -f ~/.ssh/id_rsa

Note, that I above explicitly provided the new private RSA key with an empty passphrase
which basically is from the security standpoint a pretty poor choice.
A better solution would be to omit the -N switch and enter a passphrase,
then start the ssh-agent and ssh-add your key.
But this would at least once require interactive user input.
Now you need to distribute your new public RSA key to any remote host where you want to run commands on.
This requires that you can login there (i.e. know some user/passwd),
and that this user also already has a correctly set up $HOME/.ssh directory.
If this is the case you can next scp the key in the proper place by issuing
Code:
$ ssh remuser@remhost 'cat >>.ssh/authorized_keys' < ~/.ssh/id_rsa.pub

If all went well you are now ready to run commands remotely that you could schedule by cron.
e.g.
Code:
$ ssh -i ~/.ssh/id_rsa -l remuser remhost /usr/sbin/ifconfig -a

or any other command that remuser has permissions to execute on remhost.
You can pipe its output into grep locally (just append "| grep whatever"),
or do the parsing also remotely.
In that case you need to quote the pipe by prepending a backslash
(in fact any meta character that your local shell would otherwise interpret).
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

using cut to extract info

a simple question, how can i use cut (after using grep) to extract the last four digits on a line. so say i had a string http://blabla:9020, how would I extract the port?? -Fez (4 Replies)
Discussion started by: hafhaq
4 Replies

2. AIX

need to extract info from log files

hi guys i need to extract information from log files generated by an application. log file has the following lines for each process.. ---------------------------------------------- Fri Aug 03 12:06:43 WST 2007 INFO: Running project PROJECT1 Fri Aug 03 12:06:43 WST 2007 INFO: Source Files... (7 Replies)
Discussion started by: kirantalla
7 Replies

3. AIX

Extract info

Anyone have a better idea to automate extraction of info like ... "uname" "ifconfig" "ps efl" "netstat -ao" etc. from several hundred aix, solaris, red hat boxes? without logging into each box and manually performing these tasks and dumping them to individual files? thanks for any input (1 Reply)
Discussion started by: chm0dvii
1 Replies

4. Shell Programming and Scripting

Extract info from csv

I have some input file, which contains some lines which are comma separated. Eg. a,b,id=999],d d,f,g,id=345],x x,y,x,s,id=677],y I run a loop to read the lines one by one. What i want is to extract the value on the right of id=. I cannot do it by Awk, since the column number is not fixed.... (5 Replies)
Discussion started by: indianjassi
5 Replies

5. Shell Programming and Scripting

how to extract info from a file using awk

Dear all I have a file call interfaces.txt Filename: interfaces.txt How can I extract the information at below? ABC_DB_001 hostname1 20901 ABC_DB_002 hostname2 20903 ABC_DB_003 hostname3 20905 Currently I am using a very stupid method grep ^ABC interfaces.txt > name.txt grep... (3 Replies)
Discussion started by: on9west
3 Replies

6. IP Networking

Best reference for understanding low level info on nic cards drivers and functionality

Hi, What is the best reference that gives in detail on nic cards configuration , assigning multiple ip addresses to a single interface, netlink library etc and all basic stuff at this level..? Thanks (2 Replies)
Discussion started by: Gopi Krishna P
2 Replies

7. Shell Programming and Scripting

How to extract info from pings.?

Hi guys, new to this forum. I am currently trying to extract the times from pinging a domain and list the top 3 and then also do the opposite i.e. list the bottom 3. so if I had this as a ping result (the bold part is what I want): 64 bytes from 193.120.166.90: icmp_seq=10 ttl=128 time=34.8... (5 Replies)
Discussion started by: acoding
5 Replies

8. Shell Programming and Scripting

Compare two files and extract info

Hello, I have two files which look like this File 1 Name test1 status P Gene1 0.00236753 1 1.00E-01 Gene2 0.134187 2 2.00E-01 Gene3 0.000608716 2 3.00E-01 Gene4 0.0016234 1 4.00E-01 Gene5 0.000665868 2 5.00E-01and file 2 No Pos ... (2 Replies)
Discussion started by: nans
2 Replies

9. Shell Programming and Scripting

Extract info from sar output

Hi I have an output of sarcommand which is as follows: 10:22:18 bread/s lread/s %rcache bwrit/s lwrit/s %wcache pread/s pwrit/s 10:23:18 0 398 100 5 13 64 0 0 10:24:18 0 332 100 5 15 65 0 0 10:25:18 0 ... (7 Replies)
Discussion started by: fretagi
7 Replies

10. Shell Programming and Scripting

Help with awk to extract additional info

Hi I use multipath linux command to get LUNs info and find out if any failed. # multipath -ll >/tmp/mpfail # cat /tmp/mpfail multipath.conf line 109, invalid keyword: user_friendly_names multipath.conf line 153, invalid keyword: user_friendly_names multipath.conf line 193, invalid... (4 Replies)
Discussion started by: prvnrk
4 Replies
ESHCONFIG(8)						    BSD System Manager's Manual 					      ESHCONFIG(8)

NAME
eshconfig -- configure Essential Communications' HIPPI network interface SYNOPSIS
eshconfig [-estx] [-b bytes] [-c bytes] [-d filename] [-i usecs] [-m bytes] [-r bytes] [-u filename] [-w bytes] [interface] DESCRIPTION
eshconfig is used to configure device-specific parameters and download new firmware to the Essential Communications RoadRunner-based HIPPI network interface. The interface is very sensitive to the DMA performance characteristics of the host, and so requires careful tuning to achieve reasonable performance. In addition, firmware is likely to change frequently, which necessitates a reasonably easy way to update that firmware. Available operands for eshconfig: -b bytes Adjust the burst size for read (by NIC of host memory) DMA. -c bytes Adjust the burst size for write (by NIC of host memory) DMA. -d filename Filename for file to download into NIC firmware. This must be a file in the standard Essential format, with :04 preceding every line, and a tag line at the end indicating the characteristics of the firmware file. -e Write data to EEPROM. Normally, setting tuning parameters will only persist until the system is rebooted. Setting this parameter ensures that the changes will be written to EEPROM. -i usecs Interrupt delay in microseconds. -m bytes Minimum number of bytes to DMA in one direction (read or write) before allowing a DMA in the other direction. Tuning this prevents one direction from dominating the flow of bytes, and artificially throttling the NIC. -r bytes Bytes before DMA starts for read (from host to NIC). This controls how soon the DMA is triggered; until this many bytes are requested, the DMA will not begin. -s Show statistics for the HIPPI NIC. Repeat the option to suppress non-zero statistics. -t Show current tuning parameters on the host. -u filename Name of file to which the NIC firmware should be uploaded. Not currently supported. -w bytes Number of bytes required before write (from NIC to host) DMA is started. Until this many bytes are ready to be written, the DMA will not start. -x Reset the NIC. This is necessary for the HIPPI-FP support, as ifconfig(8) will no longer physically reset the NIC when the inter- faces goes up and down. Only the super-user may modify the configuration of a network interface. DIAGNOSTICS
Messages indicating the specified interface does not exist or the user is not privileged and tried to alter an interface's configuration. SEE ALSO
esh(4), ifconfig(8) HISTORY
The eshconfig command first appeared in NetBSD 1.4. BSD
June 17, 2005 BSD
All times are GMT -4. The time now is 01:19 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy