Auto Remote SSH key setup


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Auto Remote SSH key setup
# 1  
Old 06-09-2012
Auto Remote SSH key setup

Hi Guys!!

I am trying to get around the complex situation, i have a task to complete, Like to setup the remote SSH key automatically by providing the root login details, ip and ssh port once to the script input and once its tested and accepted the next ssh should be password less,

script input will be
1) remote system IP
2) root password
3) ssh port
Expected Result : will automatically get login with above inputs and add will setup the public key to authorized_keys for further communication.

I have tried but the password which i am trying to provide to script is including special words like @@#$$%%&%^&%&()_= randomly which causing an issue

How i can make the script to accept the above inputs and setup the ssh key in remote system. Smilie

Thanks in advance.
Smilie

---------- Post updated 06-09-12 at 01:44 AM ---------- Previous update was 06-08-12 at 11:23 PM ----------

Had it working with below now Smilie

Code:
#!/bin/bash
################################
#       SilvesterJ
#
################################
FILE="/root/.ssh/id_rsa.pub"
LOCALIP=`hostname -i`
echo "Enter Destination server IP:"
read Dest_IP
echo "Enter Destination server SSH port:"
read Dest_PORT
CONNECTCMD="ssh  $Dest_IP -p $Dest_PORT "
RSYNC="rsync -vrplogDtH  -e \"ssh -p $Dest_PORT\" "
if [ -f $FILE ];
then
echo "Key is already setup on local Server, Good to Go.."
else
echo "Key Does not exists!!, Setting up local SSH key.. "
ssh-keygen -f /root/.ssh/id_rsa  -N ""
fi
echo "================="
echo "enter your password Once here: "
cat  /root/.ssh/id_rsa.pub |  $CONNECTCMD  'cat >> .ssh/authorized_keys'
$CONNECTCMD  ' csf -a '$LOCALIP''
echo "All good to go with Sync Now .."



Any suggestion are Highly appreciated!!! Smilie
Thanks & Regards,
Silvester J

Last edited by DukeNuke2; 06-09-2012 at 04:23 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

scp auto logon to remote using remote authorized_keys

Hi~ i have an authorized key which it made remote host(B). i want log on without password from local(A) to the remote host(B) using authorized key of remote host. what shell i do? anybody help me. (1 Reply)
Discussion started by: tomato00
1 Replies

2. Shell Programming and Scripting

Need Help ssh key fail on remote server

Hello everyone, I need some help writing a bash script to: 1. ssh from a jumpserver to 50 remote servers logging in automatically using ssh keys and capture if zabbix is running by running a "ps -ef | grep zabbix" and output to a logfile capturing the server hostname and ps -ef output to... (2 Replies)
Discussion started by: vtowntechy
2 Replies

3. UNIX for Dummies Questions & Answers

Auto ENTER key on TERM

I'm working in a UNIX box that's owned by a vendor. They have it set up by State, meaning when I need to program script related to certain States, I type in, for example, "CA", it goes to a whole other terminal: ddqsw:pts/2:login miller CA TERM = ( vt100 ) When I do this I have to hit... (7 Replies)
Discussion started by: shorty
7 Replies

4. IP Networking

Cygwin remote ssh with key authentication method

Hi experts, I am not sure in which forum to submit this question. If this is not the correct place then please let me know where to submit this thread. My requirement is to invoke windows batch scripts from linux shell script. Hence, I have installed openssh in Cygwin on the windows machine.... (2 Replies)
Discussion started by: ahmedwaseem2000
2 Replies

5. 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

6. 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

7. Shell Programming and Scripting

how to ssh to remote unix machines using private/public key

hello, iam able to ssh to a linux server from a linux server called "machine1" using the private/public key method, so I dont need to enter any password when I run my script but iam not able to ssh from machine1 to a UNIX server, access is denied. note that I am using an application id which is... (6 Replies)
Discussion started by: wydadi
6 Replies

8. AIX

ssh public key setup questions.

Hi all, I have N number of AIX hosts, where I need to login frequently and do some routine tasks (run some scripts). I need to setup ssh public/private key, so I can auto-login via a master (wrapper) script and run each script in each server. I am trying to setup/generate ssh keys, but am... (6 Replies)
Discussion started by: haroon_a
6 Replies

9. SCO

SCO 5.0 setup auto reboot

Hello, How do a schedule a reboot of a SCO 5.0 box like every wednesday at 3:30 am. Doesn't have a /etc/crontab file like our Suse boxes have. Thanks for any help. (6 Replies)
Discussion started by: benefactr
6 Replies

10. Solaris

Esc key/Auto-fill

I'm an HPUX/Linux guy, who appreciates occasionally hitting the Esc key for Auto-fill... Does sunOS have anything like this? This is my 1st post, and I didn't want to waste it :D thanks, manuel (3 Replies)
Discussion started by: mr_manny
3 Replies
Login or Register to Ask a Question