Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am trying to write a bash function shown below.I am trying to scp my .bashrc to the target machine.I want to do modify the following function in the below two ways.

1.I want to enter the password only once.(Can I cache the password entered for scp and use the same for ssh)

2.I also want to execute bash --rcfile from the server rather then from my machine.

export_bashrc() {

    scp ~/.bashrc $1:/root/ws_karthik
    ssh $1
    bash --rcfile /root/ws_karthik/.bashrc  

}

Can anyone suggest how to get around this issue.

share|improve this question

1 Answer 1

  1. Take a look at sshpass. If you haven't installed a configuration management tools such as: Puppet, Chef, ... I think you should setup public key authentication and use pssh to do a same command parallel on many servers at a time. (pscp to copy your ~/.bashrc)

  2. $ ssh -t $1 'bash --rcfile /root/ws_karthik/.bashrc'

Why didn't you copy ~/.bashrc to the home folder of ssh user?

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.