- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Using scp in a script without inputing passwords
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-14-2001 09:27 AM
тАО12-14-2001 09:27 AM
Using scp in a script without inputing passwords
I am trying to use scp (secure copy) to move files from one server to another. However, I don't want to have to input a password each time because I want to run scp in a script. I followed these steps so I don't have to input a password each time:
1. ssh-agent /bin/sh (substitute the name of your favorite command shell)
2. ssh-add, and then type your SSH passphrase
3. ssh machine-name
...but this only lasts until I end the session. Is there a way to set this up, so a script can run daily without the need of a password? Thanks, Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-14-2001 09:32 AM
тАО12-14-2001 09:32 AM
Re: Using scp in a script without inputing passwords
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-14-2001 10:03 AM
тАО12-14-2001 10:03 AM
Re: Using scp in a script without inputing passwords
Thanks for any help,
Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-14-2001 10:06 AM
тАО12-14-2001 10:06 AM
Re: Using scp in a script without inputing passwords
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-14-2001 10:14 AM
тАО12-14-2001 10:14 AM
Re: Using scp in a script without inputing passwords
I had ran into the same problem few months back and the solution i came up with was , using the following wrapper script:
The key thing to note in the below script is the way i am calling the ssh-agent2 in the shell line itself!
****
#!/usr/local/bin/ssh-agent2 /bin/ksh
echo $1 >/tmp/scp_wrapper.log 2>&1
/usr/local/bin/ssh-add2 /home/userid/.ssh2/id_dsa_1024_a
/usr/local/bin/scp $* > /home/userid/scp.log 2>&1
***
And then calling this wrapper script through a master script using the command:
su - userid -c "$SOURCE_DIR/scp_wrapper.ksh $SOURCE_DIR/$TARFILE userid@$REMOTE_HOST:$REMOTE_DIR"
(Here i am copying a tar file across to another system)
Ofcourse, all this is assuming you have already setup the keys and running the sshd daemons on both the boxes.
HTh
raj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-17-2001 04:39 PM
тАО12-17-2001 04:39 PM
Re: Using scp in a script without inputing passwords
To run scp without a password, you should make use of trusting of public keys.
I have been using scp in my cron job to propagate configuration files to a backup server at periodic intervals.
Below configuration pertains to what I have implemented for my environment based on SSH2 protocol, using opensource SSH Communication implementation. The last version I know is ssh-3.0.1 for this implementation.
On your CLIENT:
==============
1) Login to your user account, then run ssh-keygen to generate the public key on the client user@machine you are scp'ing from.
user> ssh-keygen
ssh-keygen will create a .ssh2 directory and store your public key into a file (default filename id_dsa_1024_a.pub) and your private key into a file (default filename id_dsa_1024_a).
2) In your identification file, insert the Identification Key reference.
client_user> cd $HOME/.ssh2
client_user> vi identification
IdKey id_dsa_1024_a
3) Copy your public key (id_dsa_1024_a.pub) to the server (into the .ssh2 directory) which you are scp'ing to.
On your SERVER:
==============
1) Create the .ssh2 directory. Alternatively, also run ssh-keygen if you want to use this server_user account to scp to another server2_user account.
server_user> cd $HOME
server_user> mkdir .ssh2
server_user> chmod 700 .ssh2
2) In the authorization file, insert your public key reference.
server_user> cd .ssh2
server_user> vi authorization
Key id_dsa_1024_a.pub
Initialization:
==============
1) During your first scp, it may prompt you whether you would like to save the host key because if it is the first time you are scp'ing from this client to that server.
2) Note that your /etc/ssh2/sshd2_config on your server must allow for publickey authentication method.
3) Subsequently your scp should work based on automatic public key authentication, rather than interactive password mode.
Hope this helps. Regards.
Steven Sim Kok Leong
Brainbench MVP for Unix Admin
http://www.brainbench.com