Go Back   Cyber Tech Help Support Forums > Operating Systems > Linux

Notices

Reply
 
Topic Tools
  #1  
Old August 18th, 2017, 03:42 PM
CyberTrek CyberTrek is offline
Senior Member
 
Join Date: Aug 2008
Location: NC, USA, Earth, Sector 001
Posts: 503
Using RSA Key to SSH

I have been at this simple thing and I know I am missing something. Some sort of combo of something. I have tried many things I found online and can not get this to work.

This is a virtual I am on:

[MYNAME@vd-MYNAME scripts]$ lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarchrinting-4.1-amd64rinting-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 7.1.1503 (Core)
Release: 7.1.1503
Codename: Core

I am trying to make this script work:

[MYNAME@vd-MYNAME scripts]$ cat ifc
#!/bin/bash

read -p "Enter first SITE number: " startSITE
read -p "Enter last SITE number: " stopSITE

#ssh -i /home/MYNAME/ssh/config

for x in `seq $startSITE $stopSITE`
do for n in 1 2
do ssh -i /home/MYNAME/ssh/id_rsa root@SITE$x-n$n ifconfig eth0; done; done

And I have these files:
/home/MYNAME/ssh/ folder is
drwxr-xr-x 2 MYNAME users 49 Aug 18 15:55 ssh

Contents are:
-rw------- 1 MYNAME users 124 Aug 18 15:55 config
-rw------- 1 MYNAME users 1675 Aug 17 22:53 id_rsa
-rw-r--r-- 1 MYNAME users 1675 Aug 17 22:55 id_rsa.ori

[MYNAME@vd-MYNAME ssh]$ cat config
Host vxms* device1* device2*
IdentityFile /home/MYNAME/ssh/id_rsa
StrictHostKeyChecking no
UserKnownHostsFile=/dev/null
User root

I should be able to log into these devices without having to add in the password each time, using the id_rsa file, but it keeps asking.

[MYNAME@vd-MYNAME scripts]$ ./ifc
Enter first SITE number: 1000
Enter last SITE number: 1000
The authenticity of host 'SITE1000-n1 (10.105.87.238)' can't be established.
RSA key fingerprint is f2:25:48:f0:97:f8:10:30:79:96:54:4f:22:cb:09:f8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'SITE1000-n1,10.106.86.226' (RSA) to the list of known hosts.
root@SITE1000-n1's password:

All logins are "root."

Can someone please assist in what I am doing wrong?

Thank you.

Last edited by CyberTrek; August 18th, 2017 at 06:40 PM.
Reply With Quote


  #2  
Old August 22nd, 2017, 02:43 PM
CyberTrek CyberTrek is offline
Senior Member
 
Join Date: Aug 2008
Location: NC, USA, Earth, Sector 001
Posts: 503
It was an issue with the id_rsa file for me. I used one from 2016 and it worked. I pointed my script to that file.
I did not need a .ssh folder or anything extra.
My script is simply this with the new file location of an old file I had early 2016.
=============================
#!/bin/bash

read -p "Enter first site number: " startsite
read -p "Enter last site number: " stopsite

for x in `seq $startsite $stopsite`
do for n in 1 2
do ssh -i /home/name/work/keys/site_id_rsa root@site$x-n$n "ifconfig eth0"; done; done
=============================
And it works... for the moment.
Reply With Quote
Reply

Bookmarks

Topic Tools

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 On
HTML code is Off

Forum Jump




All times are GMT +1. The time now is 11:49 PM.