1

i want to place a script file on other machine root . here is my terminal command

scp /var/www/html/script.sh root@192.168.1.7:script.sh

it asks for root password. i enter correct root password but it says

Permission denied, please try again.

Can anybody help?

muru
  • 197,895
  • 55
  • 485
  • 740
Sony Khan
  • 111
  • 1
  • 6

2 Answers2

0

By default openssh will denied any root login attempt. However, this can be allowed by modifying /etc/ssh/sshd_config on the server side.

Make sure this line sets to yes and no commented out:

PermitRootLogin yes

And then reload your sshd.

However, above setup is not a good security practice. Instead use pubkey login.

the config line should be:

PermitRootLogin without-password.

  1. On source machine genereate key, follow the wizard:
    ssh-keygen -t rsa

  2. Above command will create .ssh/id_rsa.pub and .ssh/id_rsa containing public and private key pair. You need to copy .ssh/id_rsa.pub content into the destination machine /root/.ssh/authorized_keys. Make the directory and file if its not exist and make sure the ownership of the authorized_keys is 600.

  3. Now try scp attempt, it will asks for password that you have entered in step 1.

0

Presuming you have have password-less sudo access, the following should work:

$ echo "My test file" > test 
$ scp test sudo_user@example.com:/tmp/
test
$ ssh sudo_user@example.com "sudo mv /tmp/test /"
$ ssh sudo_user@example.com "cat /test"
My test file
  1. Create a test file.
  2. Copy file to temp directory.
  3. Move file to root directory.
  4. Test that file is on the root directory.
Batandwa
  • 153