LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-25-2016, 01:00 AM   #1
P.G.Krish
Member
 
Registered: Jun 2016
Distribution: Ubuntu
Posts: 64

Rep: Reputation: Disabled
Lightbulb Grapping local ip using mac


I gather all my local ip using arp-scan , Then filter particular system ip by mac address, And connect automatically to that particular system using ssh. I tried the following commands through piping
Quote:
sudo arp-scan --localnet|grep 10|cut -c1-12|xargs ssh myuser@
Here 1c in grep is the mac address starting letter of my system.

Its return the following error

Quote:
ssh: Could not resolve hostname : Name or service not known

xargs: ssh: exited with status 255; aborting
 
Old 11-25-2016, 02:33 AM   #2
ferrari
LQ Guru
 
Registered: Sep 2003
Location: Auckland, NZ
Distribution: openSUSE Leap
Posts: 5,863

Rep: Reputation: 1152Reputation: 1152Reputation: 1152Reputation: 1152Reputation: 1152Reputation: 1152Reputation: 1152Reputation: 1152Reputation: 1152
I'm assuming that the following yields one IP address
Code:
sudo arp-scan --localnet|grep 10|cut -c1-12
This should work for you
Code:
sudo arp-scan --localnet|grep 10|cut -c1-12|xargs -L 1 -I host ssh user@host
More info about using xargs
Code:
man xargs
Similar asked here...
http://unix.stackexchange.com/questi...-multi-command

Last edited by ferrari; 11-25-2016 at 02:39 AM.
 
1 members found this post helpful.
Old 11-25-2016, 02:40 AM   #3
ferrari
LQ Guru
 
Registered: Sep 2003
Location: Auckland, NZ
Distribution: openSUSE Leap
Posts: 5,863

Rep: Reputation: 1152Reputation: 1152Reputation: 1152Reputation: 1152Reputation: 1152Reputation: 1152Reputation: 1152Reputation: 1152Reputation: 1152
BTW, I noticed that you mentioned
Quote:
Here 1c in grep is the mac address starting letter of my system.
but your command was
Code:
sudo arp-scan --localnet|grep 10...
 
Old 11-25-2016, 04:12 AM   #4
P.G.Krish
Member
 
Registered: Jun 2016
Distribution: Ubuntu
Posts: 64

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by ferrari View Post
BTW, I noticed that you mentioned

but your command was
Code:
sudo arp-scan --localnet|grep 10...
Hey ,
Thanks for info, But even i tried with this , I got the same error
 
Old 11-25-2016, 04:15 AM   #5
P.G.Krish
Member
 
Registered: Jun 2016
Distribution: Ubuntu
Posts: 64

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by ferrari View Post
I'm assuming that the following yields one IP address
Code:
sudo arp-scan --localnet|grep 10|cut -c1-12
This should work for you
Code:
sudo arp-scan --localnet|grep 10|cut -c1-12|xargs -L 1 -I host ssh user@host
More info about using xargs
Code:
man xargs
Similar asked here...
http://unix.stackexchange.com/questi...-multi-command
Code:
sudo arp-scan --localnet|grep 10|cut -c1-12|xargs -L 1 -I host ssh 

user@host
Why did you add host here?
 
Old 11-25-2016, 05:28 AM   #6
ferrari
LQ Guru
 
Registered: Sep 2003
Location: Auckland, NZ
Distribution: openSUSE Leap
Posts: 5,863

Rep: Reputation: 1152Reputation: 1152Reputation: 1152Reputation: 1152Reputation: 1152Reputation: 1152Reputation: 1152Reputation: 1152Reputation: 1152
It is used as a variablle
 
Old 11-25-2016, 06:33 AM   #7
P.G.Krish
Member
 
Registered: Jun 2016
Distribution: Ubuntu
Posts: 64

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by ferrari View Post
It is used as a variablle
Hai ferrari,
Its just a show a welcome message instead opening a shell
Quote:
Pseudo-terminal will not be allocated because stdin is not a terminal.
Welcome to Ubuntu 15.10 (GNU/Linux 4.2.0-16-generic x86_64)

* Documentation: https://help.ubuntu.com/

Your Ubuntu release is not supported anymore.
For upgrade information, please visit:
http://www.ubuntu.com/releaseendoflife

New release '16.04.1 LTS' available.
Run 'do-release-upgrade' to upgrade to it
I want a interactive shell
 
Old 11-25-2016, 07:12 AM   #8
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
be sure to have your hostname you want to use with its respective ip in your hosts file, as well. It looks to that to resolve addresses and hostnames. (i think first, then goes to the DSN server, if I remember correctly)

Last edited by BW-userx; 11-25-2016 at 07:14 AM.
 
1 members found this post helpful.
Old 11-27-2016, 10:30 PM   #9
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,376

Rep: Reputation: 2755Reputation: 2755Reputation: 2755Reputation: 2755Reputation: 2755Reputation: 2755Reputation: 2755Reputation: 2755Reputation: 2755Reputation: 2755Reputation: 2755
@BW-userx: the order is set in /etc/nsswitch.conf ; as you say, normally 'files' first (for some value of 'normal )
My laptop has:
Code:
#hosts:     db files nisplus nis dns
hosts:      files dns
 
  


Reply

Tags
piping, terminal


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
MAC-forced forwarding/local proxy arp in linux? edong23 Linux - Networking 5 03-26-2014 09:58 PM
[SOLVED] MAC spoofing using rc.local? m_yates Debian 3 02-08-2011 09:18 AM
finding mac address of a machine on local network aliabbass Linux - Networking 5 12-21-2010 04:33 PM
clamd upgradation in remote mach through local mac by script to be run on local mach Narayandutt Programming 3 11-29-2006 10:00 AM
mac address of local machine sadafwaqas Linux - Networking 3 05-19-2006 04:39 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:56 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