I'm sure you'd have received a lot of questions like this, but I couldn't find anything relevant to my problem in the first search. Sorry in advance if this is a repeated question.
I'm trying to do an SSH inside a shell script and expect the shell script to connect to a remote server (for deleting a few files and another script for reboot). I have the following challenges:
1. I know the username/password for the remote server, but I cannot pass it via terminal.
2. I've done the RSA authentication in the past, but the server where I'm writing the script doesn't have RSA authentication enabled (in the
file). So, creating the
and pasting the public key inside authorized_keys doesn't work for me.
3. I don't have
or
command in the server. When I try these commands, the terminal says unknown command.
I guess there's no way I can write the script here! Let me know if you think otherwise!
Yes, we answer this a lot. To discourage scripting with a password, it is read from /dev/tty not stdin.
You should set up PPKey authentication and not use a password. I think there are alternatives to RSA, some free. Why can't they turn it on? Confused security policy makers?
If you are incurably into bad security, use expect to drive ssh so you can write a password from the script through expect's pseudo tty. You could also use 'ssh localhost' trusted PPKey to set up such an intermediate pseudo tty.
You could set up reverse trust and have a process on their end connect to you: once connected, you can achieve the same thing.
You could achieve the same result with another secure service, like https.
Reverse trust is to allow the remote host PPKey access to the local host, so scripts there can connect without password and send commands, data from commands on the remote system, etc. Pull not push.
You can use 'ssh localhost -tt' or any other tool that creates a new tty. Expect is open source, so you can get it. What o/s?
Thanks guys! I somewhat realized the reverse trust in a different way and like DGPickett said, I pulled (hosted the original script on the remote) and it worked. Thanks very much!
Hello,
I am writing a shell script in which i do ssh to remote server and count the number of files there and then exit. After the exit the shell script terminates which i believe is expected behavior. Can some one suggest me a way where even after the exit the script execution resumes.
... (2 Replies)
How do I use the ssh command to connect to another server without the password prompt?
I use: ssh user@host and it prompts for the password.
how do I include the password in the ssh command?
alternatively, how do you execute 1 command from server A on server B?
thanks,
... (4 Replies)
i want use ssh on the host01 to execute autoexec.sh on the host02 like following :
host01> ssh host02 autoexec.sh
autoexec.sh include nohup command like follwing :
nohup /home/jack/deletedata.sh &
after i execute ssh host02 autoexec.sh one the host01. i can't found deletedata.sh... (1 Reply)
Hello
I have a Zabbix Server were Linux kernel version 2.6.26-2-amd64 is running.
now my Question how can i make a script that does:
- connect with ssh to a device
- get the systeminfo (but only the interfaces, mac adresses, serialnumber and Software version)
- write the output in a file
... (18 Replies)
Hi all,
I am trying to write a script in shell which can connect me to a remote server and run some commands my problem is i cant pass the password barrier.I read a lot of articles where bloggers have suggested not to use telnet and to use something more secure like ssh.I tried ssh but as soon... (8 Replies)
hi all,
needed some help writing a script (preferably in ksh) which :
1) detects if a file with ext '.kbs' has been changed. This file always sits in a particular dir.
2) if file has been changed then scp that file from one serverA to another serverB.
so far i have not done any... (2 Replies)
Hi All,
I am using ssh in my shell script. Can any one please suggest me option so that i can avoid the login message as below in the execution:
NOTE:
Please note that you have logged into the newer version of server "gabbro"
*******
Performing functions to this computer withe the... (6 Replies)
Hi all,
Just like to ask if it is possible to do the following:
1. Have a shell script that calls ssh username@destinationhost
2. Upon successful verification, we ssh into the destination host and automatically use ksh to run a shell script that resides in the destination host. (Hopefully no... (8 Replies)
Hi Floks!
This is Sravan!
I am new to linux and I am trying to write bash shell script in which I want to change the user but the statements which are after the "su " command are not working that I mean I want to execute some statements as the changed user
here is the code
... (2 Replies)