Stuck again..verify an auth key-then create on if not there


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Stuck again..verify an auth key-then create on if not there
# 1  
Old 02-11-2010
Stuck again..verify an auth key-then create on if not there

Good morning!!!

Im trying to create a script that will verify an auth key-then create on if not there. IThe script is trying to be vague to be used on whatever machine I choose.

Ok so heres the code:
Code:
#!/bin/bash
KEY=~root/.ssh/id_rsa.pub
Host=$1
Key=`ssh $Host "ls -l $KEY"`
 
if [ $Key = "" ];then
ssh $Host "ssh-keygen -b 2048 -t rsa"
fi

I keep getting an error at the Key=

Thanks in advance Ben

Last edited by Scott; 02-11-2010 at 04:45 AM.. Reason: Fixed code tags
# 2  
Old 02-11-2010
Shouldn't this
Code:
~root/.ssh/id_rsa.pub

be either
Code:
/root/.ssh/id_rsa.pub 
or 
~/.ssh/id_rsa.pub

# 3  
Old 02-11-2010
Thanks so much! I keep getting an error at the key=`ssh part.......?
# 4  
Old 02-11-2010
Quote:
Originally Posted by bigben1220
Thanks so much! I keep getting an error at the key=`ssh part.......?
What is the error?
# 5  
Old 02-11-2010
Error message:


ssh: Could not resolve hostname ls -l //.ssh/id_rsa.pub: no address associated with name
./auth_keys[8]: test: Specify a parameter with this command.

Thanks
# 6  
Old 02-11-2010
try this

Code:
#!/bin/bash
KEY="/root/.ssh/id_rsa.pub"
Host=$1
ssh $Host "if [ ! -f $KEY ]; then ssh-keygen -b 2048 -t rsa ; fi"

# 7  
Old 02-11-2010
Error after making xsoops changes:


ssh: Could not resolve hostname if [ ! -f //.ssh/id_rsa.pub ]; then ssh-keygen -b 2048 -t rsa ;
fi: no address associated with name
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Filter logs for key words and create an index

well, im a total novice of unix commands and shell scripting, i never made anything. But yesterday in my work i was working with a lot of log files and i was wondering if there is a command for doing something like this: i have a bunch of files with text like this: blablabla errorcode1... (11 Replies)
Discussion started by: matius_88
11 Replies

2. Shell Programming and Scripting

Bash script to create rsa key pair

Hello all, I am setting up a cluster of Mac Pro's which need to be able to talk to a master computer, traffic between the nodes and the master needs to take place without a ssh key. I need a script that will create a security key, save it to the default place, enter the password as no password.... (2 Replies)
Discussion started by: sdl27789
2 Replies

3. UNIX for Dummies Questions & Answers

how to create a public/private key using ssh-keygen

Hi, please guide me create a public/private key using ssh-keygen, lets say I have been access to server named pngpcdb1with a userid and password ...!!! and also please explain in detail the concept of these keys and ssh as I was planning to use them in ftp related scripts..! Thanks in... (1 Reply)
Discussion started by: rahul125
1 Replies

4. Solaris

Solaris 8 ssh public key authentication issue - Server refused our key

Hi, I've used the following way to set ssh public key authentication and it is working fine on Solaris 10, RedHat Linux and SuSE Linux servers without any problem. But I got error 'Server refused our key' on Solaris 8 system. Solaris 8 uses SSH2 too. Why? Please help. Thanks. ... (1 Reply)
Discussion started by: aixlover
1 Replies

5. AIX

ssh public key auth "Remote login for account is not allowed" ?

Hello, Using AIX 6.1 boxes. User user1 connects from box A to box B using ssh. When password authentication is used everything is fine. When I configure user1 to use public key authentication sftp client works fine(no password asked), but ssh client fails. This is sshd log: Accepted publickey... (3 Replies)
Discussion started by: vilius
3 Replies

6. Shell Programming and Scripting

Difference in auth key commands?

Good morning! What is the difference between: ssh-keygen -t rsa and ssh-keygen -b 2048 -t rsa? Thanks Bigben (2 Replies)
Discussion started by: bigben1220
2 Replies

7. UNIX for Dummies Questions & Answers

ssh pub key auth - can some please guide me idiot proof

hello. can somebody please idiot proff simple guide me how to set up ssh public key authenciation? i am stuck, i tried long and googled a lot but i cant get it. thanks in advance. (4 Replies)
Discussion started by: scarfake
4 Replies

8. UNIX for Dummies Questions & Answers

Pressing backspace key simulates enter key

Hi, Whenever i press the backspace key, a new line appears, i.e. it works like a enter key. :confused: Thanks (2 Replies)
Discussion started by: vibhor_agarwali
2 Replies

9. UNIX for Advanced & Expert Users

Apache auth question

While not technically a unix question, I was hoping for some help from you all- I've got an Apache 1.3.x server, and I am using basic auth from the pam_auth module and winbind on the back of that. What I get is a relaly sleek authentication for my Windos domain users, however, as they are wont... (1 Reply)
Discussion started by: loadc
1 Replies
Login or Register to Ask a Question