LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   SCP without Password help (https://www.linuxquestions.org/questions/linux-networking-3/scp-without-password-help-515616/)

ignignokt 01-02-2007 10:35 AM

SCP without Password help
 
Im trying to send a file in a script from one Solaris box to another. I used the following commands to set up the ssh but I am still being prompted for a password.

Code:

ssh-keygen -t rsa
ssh-keygen -t dsa
cat id_dsa.pub > authorized_keys
cat id_rsa.pub >> authorized_keys
rm id_dsa.pub id_rsa.pub
chmod 700 authorized_keys

Then I sent authorized_keys to the remote server's / .ssh directory. Im still being asked for the pass.

The user on the origin server is root and the user on the remote server is oracle. Do they have to be the same user on both machines?

theNbomr 01-02-2007 11:00 AM

I think the permissions on your authorized_keys file should be 600. You will have to set this at the remote end after copying the file. I usually copy the key file only, then perform the copy-append at the remote end, so that any prior keys are not overwritten.

I've never used both rsa & dsa encryption, only one or the other. Not sure if that is a problem.

The authorized_keys file must be owned by the uid that will be using it, oracle, in your case.

--- rod.

ignignokt 01-02-2007 11:03 AM

thanks for the reply. so on the remote machine, the authorized_keys file should be in the folder "export/home/oracle/.ssh" correct?

chort 01-02-2007 11:59 AM

You generated your keys in a rather bad way. The way you did it could have overwritten the local user's authorized_keys file, depending on what directory you're in. The correct way to do it is like:
Code:

host1 ~# ssh-keygen -t rsa
host1 ~# scp .ssh/id_rsa.pub user@host2:host1_id_rsa.pub
host1 ~# ssh user@host2
host2 ~$ mkdir .ssh
host2 ~$ chmod 700 .ssh
host2 ~$ cd .ssh
host2 .ssh$ mv ../host1_id_rsa.pub ./
host2 .ssh$ cat host1_id_rsa >> authorized_keys
host2 .ssh$ chmod 600 authorized_keys

In order to not be prompted for a password, you need to generate the key (with ssh-keygen) without a passphrase. That means when it prompts you for a passphrase while creating the key, just hit <enter> twice. If you have already created the key with a passphrase, you can use ssh-keygen -p -f ~/.ssh/id_rsa to change the passphrase. You don't need to do anything with the public key after you change the passphrase on the private key. The passphrase is only to unlock the private key so you can use it. NB: if you have a private key w/o a passphrase, that means anyone who can copy that private key can login as you to any machines that have your public key! Make sure that you protect your private key very well.


All times are GMT -5. The time now is 01:47 AM.