How do I ssh to a Raspberry PI server with shell script

Questions about applications and software
Forum rules
Before you post please read how to get help
Post Reply
deepakdeshp
Level 11
Level 11
Posts: 3925
Joined: Sun Aug 09, 2015 10:00 am

How do I ssh to a Raspberry PI server with shell script

Post by deepakdeshp » Thu Apr 26, 2018 6:57 am

Hello,
I want to ssh to the raspberry server automatically . I am able to get the ip of the pi from the following script.

Code: Select all

sudo arp-scan 192.168.0.100-192.168.0.200|grep "b8:27:eb"|awk '{print $1}'
The result is 192.168.0.120 which is the ip of raspberry pi.

Thanks in anticipation.
If I have helped you solve a problem, please add [SOLVED] to your first post title, it helps other users looking for help, and keeps the forum clean.
I am using Mint 19 Cinnamon 64 bit with AMD A8/7410 processor . Memory 8GB

deepakdeshp
Level 11
Level 11
Posts: 3925
Joined: Sun Aug 09, 2015 10:00 am

Re: How do I ssh to a Raspberry PI server with shell script

Post by deepakdeshp » Thu Apr 26, 2018 8:45 am

Now the command to run through the script is
ssh pi@192.168.0.12
The ssh password has to be provided in the script.
If I have helped you solve a problem, please add [SOLVED] to your first post title, it helps other users looking for help, and keeps the forum clean.
I am using Mint 19 Cinnamon 64 bit with AMD A8/7410 processor . Memory 8GB

deepakdeshp
Level 11
Level 11
Posts: 3925
Joined: Sun Aug 09, 2015 10:00 am

Re: How do I ssh to a Raspberry PI server with shell script

Post by deepakdeshp » Thu Apr 26, 2018 9:07 am

It gives error as follows

Code: Select all

  sudo arp-scan 192.168.0.100-192.168.0.200|grep "b8:27:eb"|awk '{print $1}'= a;ssh pi@$a
awk: cmd. line:1: {print $1}=
awk: cmd. line:1:           ^ syntax error
ssh: Could not resolve hostname : No address associated with hostname
If I have helped you solve a problem, please add [SOLVED] to your first post title, it helps other users looking for help, and keeps the forum clean.
I am using Mint 19 Cinnamon 64 bit with AMD A8/7410 processor . Memory 8GB

User avatar
Faust
Level 4
Level 4
Posts: 440
Joined: Thu Jul 14, 2016 3:40 am

Re: How do I ssh to a Raspberry PI server with shell script

Post by Faust » Thu Apr 26, 2018 10:30 am

deepakdeshp wrote:
Thu Apr 26, 2018 6:57 am
Hello,
I want to ssh to the raspberry server automatically . I am able to get the ip of the pi from the following script.

Code: Select all

sudo arp-scan 192.168.0.100-192.168.0.200|grep "b8:27:eb"|awk '{print $1}'
The result is 192.168.0.120 which is the ip of raspberry pi.

Thanks in anticipation.
I'm on a similar quest regarding ssh into Pi systems .

I can't offer you anything for your problem , I can only confirm that I get a shell on every Pi on my network
by using the same command that you put in your second post , so nothing is wrong there .
( I use Angry IP Scanner to show what devices are " chatty " on my network )

I'm looking for an ssh method that I'm comfortable with for when I'm traveling ,
and there are some security aspects that bother me .
I read a related post on here today :-

viewtopic.php?f=157&t=268395&sid=aac24c ... 5#p1462634

Please post back here if you make any progress :)
" And so it goes " - Kurt Vonnegut
The modern reality and the satirical parody are rapidly converging .

Post Reply

Return to “Software & Applications”