10-08-2008
Well, at the end I was able to make it work!
))))
Once I could get the errors (access denied!) I realised that it was actually a problem with the environmental variables so after trying again with the older posts, I had to go through the export and printenv issues.
In my environment I found two variables related to the ssh agent (SSH_AUTH_SOCK and SSH_AGENT_PID) so I added them to the script:
#!/usr/bin/ksh
export SSH_AUTH_SOCK=... (copied after the command printenv)
export SSH_AGENT_PID=... (idem)
/sftppath/scp root@remoteserver:/remotepath/remotefile /localpath/localfile
exit 0
And it worked!!!
Not easy for me as a newbie, however... I post the solution here in case it could serve for anyone.
bye!!
PD: I guess I'll have problems with the agent id again, when I login next time, anyway...
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I have a simple script that is trying to put a file that resides on a local machine to a remote machine. It runs fine manually but does not complete when scheduling to run in cron. Here is what the script looks like. Any idea what I am doing wrong here?
#!/bin/ksh
cd /path
sftp... (4 Replies)
Discussion started by: ewilson0265
4 Replies
2. Solaris
I am using a script to transfer a file from a unix host to another unix host. The code snippet for sftp in the script is as below.
sftp -oIdentityFile=$ID_FILE_NAME -oNumberOfPasswordPrompts=0 $REMOTE_USERID@$REMOTE_HOST <<EOF
cd incoming
put $REPORT_FILE... (2 Replies)
Discussion started by: msabhilash
2 Replies
3. UNIX for Dummies Questions & Answers
I have four servers that for all intents and purposes are the same (I have the same profile on all four), North, South, Brooklyn & Queens.
I have a script that scp's a file from Queens to brooklyn, and it runs just fine. I tried to replicate the script on South, to transfer a file to North, and... (1 Reply)
Discussion started by: DeCoTwc
1 Replies
4. UNIX for Dummies Questions & Answers
Hi,
I am running simple script to automate sftp transfer to remote box. I have setup public/private keys to have sftp connect automatically and have test script that list remote directory:
#!/bin/ksh
echo "OK, starting now..."
sftp userid@host <<EOI
cd dir
ls -lt
bye
EOI... (2 Replies)
Discussion started by: r1omen
2 Replies
5. Shell Programming and Scripting
the follwing script is running fine , when run from the ksh shell...it runs properly i.e. waits for a file "test.flag" and sends mail accordingly.
But when I schedule it in the crontab ...it does not run at the specified time (it never runs).
I am using ksh
####shell script starts
count=1... (4 Replies)
Discussion started by: ace@123
4 Replies
6. Emergency UNIX and Linux Support
I shall explain the situation that I am facing to the best extent possible. I require some help, as this situation is an urgent one.
I am trying to automate sending data from one AIX machine to another. A script runs that tries to push data received from an upstream application to another AIX... (7 Replies)
Discussion started by: ggayathri
7 Replies
7. UNIX for Advanced & Expert Users
Hello -
I have a production stream that is scheduled with cron to run each Monday morning. The jobs in the stream perform tasks including
FTP get, load to a DB table, and report processing.
About a month ago I was directed to begin using sftp in these jobs and since then the jobs... (12 Replies)
Discussion started by: PatrickPurfield
12 Replies
8. Solaris
On Solaris 10 server the system date won't match with the timestamp on files created by a cron jobs, Please help
here is what i get when i check for system date
infodba-ie10ux014:/tcpdv1_ie10/tcadmin/bin\n\r-> date
Tue Apr 24 15:27:43 GMT 2012at same time i executed a cron job, and checked... (4 Replies)
Discussion started by: karghum
4 Replies
9. Shell Programming and Scripting
Hi,
1)
If some job supposed to run on 1st of every month at 7 AM
In cron job when we have a blackout on the 1st ( i.e when 1st falls on a sunday ) how can we make the job run the next business day?
2) How can we run a job on 25th of every quarter 7 AM(jan,apr,jul,oct)
And if 25th... (5 Replies)
Discussion started by: System Admin 77
5 Replies
10. Shell Programming and Scripting
Hi,
I am trying to sftp using expect, but not getting through as it prompt for password is coming
Following is the code
#/usr/bin/expect > output.log
sftp medcdr@10.130.254.50
expect "password:"
send "Med@Cdr12\n"
expect "sftp>"
send "put ZTE_*201505*\r"
expect "sftp>"
send "bye\r"... (7 Replies)
Discussion started by: siramitsharma
7 Replies
LEARN ABOUT REDHAT
ssh-agent
SSH-AGENT(1) BSD General Commands Manual SSH-AGENT(1)
NAME
ssh-agent -- authentication agent
SYNOPSIS
ssh-agent [-a bind_address] [-c | -s] [-d] [command [args ...]]
ssh-agent [-c | -s] -k
DESCRIPTION
ssh-agent is a program to hold private keys used for public key authentication (RSA, DSA). The idea is that ssh-agent is started in the
beginning of an X-session or a login session, and all other windows or programs are started as clients to the ssh-agent program. Through use
of environment variables the agent can be located and automatically used for authentication when logging in to other machines using ssh(1).
The options are as follows:
-a bind_address
Bind the agent to the unix-domain socket bind_address. The default is /tmp/ssh-XXXXXXXX/agent.<ppid>.
-c Generate C-shell commands on stdout. This is the default if SHELL looks like it's a csh style of shell.
-s Generate Bourne shell commands on stdout. This is the default if SHELL does not look like it's a csh style of shell.
-k Kill the current agent (given by the SSH_AGENT_PID environment variable).
-d Debug mode. When this option is specified ssh-agent will not fork.
If a commandline is given, this is executed as a subprocess of the agent. When the command dies, so does the agent.
The agent initially does not have any private keys. Keys are added using ssh-add(1). When executed without arguments, ssh-add(1) adds the
files $HOME/.ssh/id_rsa, $HOME/.ssh/id_dsa and $HOME/.ssh/identity. If the identity has a passphrase, ssh-add(1) asks for the passphrase
(using a small X11 application if running under X11, or from the terminal if running without X). It then sends the identity to the agent.
Several identities can be stored in the agent; the agent can automatically use any of these identities. ssh-add -l displays the identities
currently held by the agent.
The idea is that the agent is run in the user's local PC, laptop, or terminal. Authentication data need not be stored on any other machine,
and authentication passphrases never go over the network. However, the connection to the agent is forwarded over SSH remote logins, and the
user can thus use the privileges given by the identities anywhere in the network in a secure way.
There are two main ways to get an agent setup: Either the agent starts a new subcommand into which some environment variables are exported,
or the agent prints the needed shell commands (either sh(1) or csh(1) syntax can be generated) which can be evalled in the calling shell.
Later ssh(1) looks at these variables and uses them to establish a connection to the agent.
The agent will never send a private key over its request channel. Instead, operations that require a private key will be performed by the
agent, and the result will be returned to the requester. This way, private keys are not exposed to clients using the agent.
A unix-domain socket is created and the name of this socket is stored in the SSH_AUTH_SOCK environment variable. The socket is made accessi-
ble only to the current user. This method is easily abused by root or another instance of the same user.
The SSH_AGENT_PID environment variable holds the agent's process ID.
The agent exits automatically when the command given on the command line terminates.
FILES
$HOME/.ssh/identity
Contains the protocol version 1 RSA authentication identity of the user.
$HOME/.ssh/id_dsa
Contains the protocol version 2 DSA authentication identity of the user.
$HOME/.ssh/id_rsa
Contains the protocol version 2 RSA authentication identity of the user.
/tmp/ssh-XXXXXXXX/agent.<ppid>
Unix-domain sockets used to contain the connection to the authentication agent. These sockets should only be readable by the owner.
The sockets should get automatically removed when the agent exits.
AUTHORS
OpenSSH is a derivative of the original and free ssh 1.2.12 release by Tatu Ylonen. Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos,
Theo de Raadt and Dug Song removed many bugs, re-added newer features and created OpenSSH. Markus Friedl contributed the support for SSH
protocol versions 1.5 and 2.0.
SEE ALSO
ssh(1), ssh-add(1), ssh-keygen(1), sshd(8)
BSD
September 25, 1999 BSD