Sponsored Content
Full Discussion: SSH/SCP Question
Operating Systems Solaris SSH/SCP Question Post 302202406 by PabloCruise77 on Wednesday 4th of June 2008 08:12:32 PM
Old 06-04-2008
Hammer & Screwdriver Solution to SSH/SCP Problem

Here's what I found after examining a co-worker's source code. Put the
following in the source host script:

#########################################################
# source_host_script
#
#
#########################################################
.
.
.

param="UPDATE"
file_update="${HOME}/${subdir}/${newfile}"

ssh ${userid}@${host} ${param} ${file_update}
retval=$?

if [ ${retval} -ne 1 -a ${retval} -ne 0 ]; then
echo "Source Code Update Failed: ${retval}"
echo "Press any key to continue"
fi

return ${retval}
}


Then put the following code in the script on your target host:

#########################################################
# target_host_script
#

#
#########################################################
.
.
.

#########################################################
# Get the command line arguments for the SSH call
#########################################################
OSSMENU_COMMAND=`echo ${SSH_ORIGINAL_COMMAND} | nawk '{print $1}`
PARAM=`echo ${SSH_ORIGINAL_COMMAND} | nawk 'NF > 1 {print $2}`
NEWFILE=`echo ${SSH_ORIGINAL_COMMAND} | nawk 'NF > 2 {print $3}`

is_scp=`echo ${OSSMENU_COMMAND} | grep "^scp" | wc -l`

########################################################
# If this is an scp then call the update control source
# code subroutine. This will copy over the latest
# version of the specified script.
# WARNING - do not do an echo or any other output to
# standard out - It will kill the scp command!
########################################################
if [ ${is_scp} -gt 0 ]; then
cd ${HOME}/${newdir}
scp -pt ${NEWFILE}
retval=$?

if [ ${retval} -ne 0 ]; then
echo "Source Code Update Failed: ${retval}"
echo "Press any key to continue"
else
chmod 755 ${NEWFILE}
fi

return ${retval}
fi
}

Its a little confusing and it still throws me each time I use it but it works. Its the only way I know how to get SCP to work when you have set up SSH keys that specify a specific script to run in for a given user.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

SSH and SCP

The following ksh script is trying to get a file's cksum then, scp it over to a remote machine - get the cksum there and then compare the two cksums to make sure they match. I am having problems setting a variable on the remote host where it can be read locally. Is this even possible - reading a... (1 Reply)
Discussion started by: berrean
1 Replies

2. BSD

SCP and ssh

I can't get ssh ans scp to work between to host on my network. I am prompted for the password and it isn't accepting the password and I know the password is correct because I am using the root password. What do I need to do to get ssh working between the two host and scp. I can putty into the... (2 Replies)
Discussion started by: rbizzell
2 Replies

3. Shell Programming and Scripting

ssh/scp - can you specify timeout?

I am scp'ing a file from a server (servera) to my server (serverb) If servera is down - the scp never times out ... it just hangs eternally.. It is possible to specify a timeout in my script - so if scp fails/hang for more than 60 seconds I assume its failed ? I am aware there is some... (3 Replies)
Discussion started by: frustrated1
3 Replies

4. AIX

ssh and scp in aix 4.3.3

I'm using scp to copy files to another company via our 4.3.3 server. I am having transfer problems right at the transfer point in scp. Below are 2 debug outputs showing the bottleneck. The lower level debug preceeds the higher level debug output. It just seems to stop and refuses to transfer... (0 Replies)
Discussion started by: oldogbert
0 Replies

5. UNIX for Advanced & Expert Users

Simulating scp through ssh

How to simulate scp command using ssh? (5 Replies)
Discussion started by: vickylife
5 Replies

6. Shell Programming and Scripting

SSH and SCP HELP

Hi all Iam using ssh and trying to change to a different user but im not able to do it. -------- Script.sh ssh user@hostname sudo rootsh whoami -------- -------- Script2.sh ssh user@hostname su - username password whoami --------- When i run the Script.sh it is connecting to... (4 Replies)
Discussion started by: coolkid
4 Replies

7. UNIX for Advanced & Expert Users

ssh and scp between comps over eth0

How can I establish a secure link (such that ssh and scp can be used) between two unix/linux machines over ethernet? (1 Reply)
Discussion started by: pyramation
1 Replies

8. UNIX for Advanced & Expert Users

Problem with ssh and scp

Hi there, I'm working with two linux servers and if I use ssh to connect from 1 to 2 everything works fine ( ..as usual:rolleyes:), while if I try to connect via ssh or to copy files through scp (as I usually do...) from 2 to 1, after the password I get this message: Connection closed by... (6 Replies)
Discussion started by: Giordano Bruno
6 Replies

9. Solaris

ssh and scp not working

Dear All, whenever i try the command ssh , it is giving the below error. ld.so.1: ssh: fatal: relocation error: file /usr/bin/ssh: symbol SUNWcry_installed: referenced symbol not found Killed For SCP also the same error is coming. Pl reply me if you have answers. Rj (4 Replies)
Discussion started by: jegaraman
4 Replies

10. UNIX for Beginners Questions & Answers

Ssh find and scp

Hello All, I have a requirement to copy few files from remote server to local, and below are the sequence ssh to the remote host finding the files with the specific condition once found scp to the local server path for (( i=0; i<${tLen}; i++ )) do ssh... (1 Reply)
Discussion started by: nextStep
1 Replies
PARALLEL-SLURP(1)														 PARALLEL-SLURP(1)

NAME
parallel-slurp - copy files from listed hosts SYNOPSIS
parallel-slurp [OPTIONS] -h hosts.txt -L destdir remote local DESCRIPTION
pssh provides a number of commands for executing against a group of computers, using SSH. It's most useful for operating on clusters of homogenously-configured hosts. parallel-slurp gathers specified files from hosts you listed. OPTIONS
-r --recursive recusively copy directories (OPTIONAL) -L --localdir output directory for remote file copies -h --hosts hosts file (each line "host[:port] [user]") -l --user username (OPTIONAL) -p --par max number of parallel threads (OPTIONAL) -o --outdir output directory for stdout files (OPTIONAL) -e --errdir output directory for stderr files (OPTIONAL) -t --timeout timeout (secs) (-1 = no timeout) per host (OPTIONAL) -O --options SSH options (OPTIONAL) -v --verbose turn on warning and diagnostic messages (OPTIONAL) EXAMPLE
An example to copy /home/irb2/foo.txt from each host. Files gathered will be stored in /tmp/outdir/hostname/foo.txt. # prallel-slurp -h hosts.txt -L /tmp/outdir -l irb2 /home/irb2/foo.txt foo.txt ENVIRONMENT
All four programs take similar sets of options. All of these options can be set using the following environment variables: o PSSH_HOSTS o PSSH_USER o PSSH_PAR o PSSH_OUTDIR o PSSH_VERBOSE o PSSH_OPTIONS SEE ALSO
parallel-ssh(1), parallel-scp(1), parallel-nuke(1), parallel-rsync(1), ssh(1) AUTHOR
Brent N. Chun <bnc@theether.org> COPYING
Copyright: 2003, 2004, 2005, 2006, 2007 Brent N. Chun NOTES
1. bnc@theether.org mailto:bnc@theether.org 03/30/2009 PARALLEL-SLURP(1)
All times are GMT -4. The time now is 12:34 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy