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

Questions about applications and software
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
deepakdeshp
Level 20
Level 20
Posts: 12340
Joined: Sun Aug 09, 2015 10:00 am

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

Post by deepakdeshp »

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.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
If I have helped you solve a problem, please add [SOLVED] to your first post title, it helps other users looking for help.
Regards,
Deepak

Mint 21.1 Cinnamon 64 bit with AMD A6 / 8GB
Mint 21.1 Cinnamon AMD Ryzen3500U/8gb
deepakdeshp
Level 20
Level 20
Posts: 12340
Joined: Sun Aug 09, 2015 10:00 am

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

Post by deepakdeshp »

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.
Regards,
Deepak

Mint 21.1 Cinnamon 64 bit with AMD A6 / 8GB
Mint 21.1 Cinnamon AMD Ryzen3500U/8gb
deepakdeshp
Level 20
Level 20
Posts: 12340
Joined: Sun Aug 09, 2015 10:00 am

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

Post by deepakdeshp »

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.
Regards,
Deepak

Mint 21.1 Cinnamon 64 bit with AMD A6 / 8GB
Mint 21.1 Cinnamon AMD Ryzen3500U/8gb
Faust

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

Post by Faust »

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 :)
Locked

Return to “Software & Applications”