I have a Solaris x86 server. I am installing patch cluster on that. Out of so many patches, any one patch is breaking its LDAP authentication and I am not able to figure out, which one is that. I have restored server and planning to apply that patch cluster again.
To figure that patch, I got an idea. While patching is running, I would want to setup a cronjob in server2, which will run a scp job to copy something with my user-id (non-root), to this server, with time-stamp.
I need the script, which can be setup in cronjob of server2 and that will pull a file with scp with my user-id and LDAP password, with time-stamp. I would want to run it every minute. After patching, I will check time-stamp, when that scp was broke and I will check in logs, which patch was applied at that time.
I tried taking help of expect with below script
Code:
#!/usr/local/bin/expect -f
# ----------------------------------------------------------------------
# For example:
# ./sshlogin hostname username password who
# ./sshlogin hostname username password uname -a
# ----------------------------------------------------------------------
# set Variables
set hostname [lrange $argv 0 0]
set username [lrange $argv 1 1]
set password [lrange $argv 2 2]
set scriptname [lrange $argv 3 3]
set arg1 [lrange $argv 4 4]
set timeout 20
# now connect to remote UNIX box (ipaddr) with given script to execute
spawn ssh -q -o NumberOfPasswordPrompts=1 -o StrictHostKeyChecking=no $username@$hostname $scriptname $arg1
match_max 100000
# Look for passwod prompt
expect "*?assword:*"
# Send password aka $password
send -- "$password\r"
# send blank line (\r) to make sure we get back to gui
send -- "\r"
expect eof
catch wait reason
set exit_status [lindex $reason 3]
send_user "EXIT CODE: $exit_status\r"
exit $exit_status
But it doesn't give me expected value and ends up with some numeric ouput
Code:
bash-3.2# /var/tmp/ssh-test.sh nproc-db34-admin broe ZAQ!2wsx uname -a
/var/tmp/ssh-test.sh nproc-db34-admin broe ZAQuptimewsx uname -a
spawn ssh -q -o NumberOfPasswordPrompts=1 -o StrictHostKeyChecking=no broe@nproc-db34-admin uname -a
Password:
bash-3.2# 255
Assuming, it is not liking format of my password, with ! mark and numeric 2
Hello experts,
OS : CentOS
Could you please help me with the following scenario :
I wish to use scp command in order to copy a file (say : f1.txt) from server 2 to server 1.
Both servers have a common user (say : user1) configured. Also, the file is owned by the same user on both... (2 Replies)
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)
Hi team,
need help on this :- trying to scp a file from A ( it could any server among hundreds not one) server to B server ( fixed ) . The script runs in a third server CFGEngine server.
a. we dont use static password ( its pin + rsa token) so , "here documents" kind of thing is not... (3 Replies)
Hi, I've been trying to develop a script that performs the parsing of a log every 1 minute and then generating some statistics. I'm fairly new to programming and this is why I come to ask if I can lend a hand.
this is my log:
xxxx 16/04/2012 17:00:52 - xxxx714 - E234 - Time= 119 ms.... (8 Replies)
Dear all,
I have two servers A and B. I want to do scp with out password between these two servers.
I created ssh-keygen and copied the id-rsa.pub file to each of them in authorized_keys.
But I could login only from B to A with out password. From A to B it is asking for a password.
... (5 Replies)
Hi
My requirement is i want to copy files from remote server to the local server and also i need to preserve the timestamp of the remote file.
By using scp -p , it is working fine in the interactive call but it is not preserving he file timestamp when i use it in the non interactive scp call... (1 Reply)
Hi,
I want to use sftp/scp without password.How can I do that ??
I plan to use script with scp/sftp and execute by cronjob ,any sample or example?? How can I test the scp/sftp working or not in the same user account , in the same red linux server?? any suggestion ??? (5 Replies)
Hello,
Do you guys know set of commands that can incorporate to sftp/scp/ssh to add password in a script to automate file transfer.
Our client is not using ssh keys authentication so we are force to create a script to pass the password into the script to transfer files via sftp/scp/ssh.
We... (4 Replies)
I like to copy a file from one server server1 from path path1 to another server server2 to path path2.
User logging in both the servers are same say user1
I tried to use ssh to generate public/private key pairs and then copy without prompting for password.
These are the steps i followed
... (5 Replies)