how can I run remotley my test script without password?
Hi all,
how can I run remotely my test script without password? lets say user named "user" at host2 that has script located on /tmp/test.sh I like to run that script on host1 using this: ssh user@host2 'bash /tmp/test.sh' the script actually runs but it ask me a password to login on host2. Is there a shortcut way so I would only just run the script next time without putting the password to host2? |
private key authentication:http://linuxproblem.org/art_9.html
|
Use google to search for 'passwordless ssh' for your distribution.
But typically it comes down to using ssh-keygen and sending up the key. Code:
ssh-keygen -t rsa |
|
thanks, seems like all of you has same idea to to solve my problem. I'll try it
|
Quote:
script from host2 is owned by user2 and located on /opt/user2/bin/test.sh but 1st for me to able to run the script from host2 I need to be logged as "user" then sudo su to "user2" running this command in host2 as user= sudo su - user2 question is I want to run the script from host1 using "user" I tried this = ssh user@host2 'sudo su - user2 -c /opt/user2/bin/test.sh' it asked the password for user2 but it gives me this error = sudo: sorry, you must have a tty to run sudo |
You can comment out the 'requiretty' line in your sudoers file, if you'd like to not require a tty.
|
Quote:
actually I'm not yet fully familiar with it |
vim /etc/sudoers
Code:
# add this |
ssh -t might work for you, it works for me to use ssh to sudo a remote script that calls another remote script.
|
Quote:
|
Quote:
#ssh user@host2 '/opt/user2/bin/test.sh' ls: cannot open directory /opt/user2/packages: Permission denied /opt/user2/bin/test.sh: line 133: kill: (23125) - Operation not permitted /opt/user2/bin/test.sh: line 136: kill: (23125) - Operation not permitted ls: cannot access /opt/user2/pkg/jboss-/server/default/deploy: No such file or directory |
Apart from 0) not using 'ls' in scripts if you are going to parse the output, 1) testing before you do something and 2) using a completely different "user" account ("user != "user2") to execute your script "ssh user@host2" I think you should cut this short by posting the actual full contents of "/opt/user2/bin/test.sh", what it should achieve, determine the owner of the process with PID 23125 and check why (sub)directory ownership doesn't match the (presumed) "user2" account.
|
All times are GMT -5. The time now is 09:12 AM. |