Script to authorize keys ....


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script to authorize keys ....
# 1  
Old 02-10-2010
Script to authorize keys ....

Hello!!

I am trying to write a script to verify if theres an id_rsa.pub, if not then create one. After creating one to send it to antoher servers authorization keys file.

Hope that makes sense-lol.

Heres what I have so far:
Code:
Cd .ssh 
Cat id_rsa.pub
If not then ssh-keygen -t rsa
Then cat .ssh/id_rsa.pub | ssh user@server 'cat >> .ssh/authorized_keys'

I know Im missing some things, but for the life of me I cant figure it out!!

Bigben

---------- Post updated at 01:33 AM ---------- Previous update was at 12:55 AM ----------

I forgot to say Thanks in advance for all help!

Bigben

Last edited by pludi; 02-10-2010 at 02:14 AM.. Reason: closed code tags
# 2  
Old 02-10-2010
Code:
[ -f ".ssh/id_rsa.pub" ] || ssh-keygen -t rsa &&
cat .ssh/id_rsa.pub | ssh user@server 'cat >> .ssh/authorized_keys'

# 3  
Old 02-10-2010
Code:
KEY=~/.ssh/id_rsa.pub
[ -f $KEY ] || ssh-keygen -t rsa && ssh-copy-id -i $KEY user@server

# 4  
Old 02-10-2010
Thanks so much!!!
Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Send keys in shell script

Hi All, Consider we have script Linux server . But we don't have permission to edit that file. When run the script, it opens a file as "/tmp/xxx0000 .txt" with few contents. Most of the time the contents doesn't required to modify and they just save and close (:wq!). So the script continues... (7 Replies)
Discussion started by: k_manimuthu
7 Replies

2. Shell Programming and Scripting

SFTP or scp with password in a batch script without using SSH keys and expect script

Dear All, I have a requirement where I have to SFTP or SCP a file in a batch script. Unfortunately, the destination server setup is such that it doesn't allow for shell command line login. So, I am not able to set up SSH keys. My source server is having issues with Expect. So, unable to use... (5 Replies)
Discussion started by: ss112233
5 Replies

3. Shell Programming and Scripting

Need an expect script to copy trusted keys

I would like an expect script that not only transfers over the trusted keys to remote hosts that I've never logged into before via ssh, but it also cats the trusted key into the ~/.ssh/authorized_ksys2 file. Essentially it would be like combining the two scripts below. But I would rather stay away... (2 Replies)
Discussion started by: master-of-puppe
2 Replies

4. Shell Programming and Scripting

how to disable keys in script

Hi there all.. How can I set keys to be disabled in a shell script menu? So people cant escape the script with Ctrl+C or someting. I have a menu people have to see and when they get out of the menu script they have to be logged off again. That all works fine. But when they Ctrl+C they just... (5 Replies)
Discussion started by: draco
5 Replies

5. AIX

How can I authorize a non-root user to do a system backup with 'mksysb'?

I use AIX 5.2 I want to allow a non-root user to do a system backup with 'mksysb' command. I try to add 'ManageBackup' Role to that non-root user but it have an error "ksh: mksysb: 0403-006 Execute permission denied." What should I do? (8 Replies)
Discussion started by: AIX122
8 Replies

6. UNIX for Dummies Questions & Answers

arrow keys / special keys

how to use the arrow keys in shell scripting. is there any special synatax / command for this. i just want to use the arrow keys for navigation. replies appreciated raguram R (3 Replies)
Discussion started by: raguramtgr
3 Replies
Login or Register to Ask a Question