ssh connection through shell script with no interruption
Hi all,
I need ssh in shell script. My requirement is:
- Take user_name and password from user (in PHP)
- Pass this to shell script which will:
- connect via ssh
- Run sql query
- Pass the results back in PHP
- Put the results to website.
I know PHP has libraries for ssh and ftp, but in my system all are disabled. So, I need to write script for this. I have already done FTP, but I am not getting any luck with ssh.
Everything else on the above list I can do, I just need ssh connection through script with no interuption.
I am using Solaris. Thanks for your help.
---------- Post updated at 01:54 PM ---------- Previous update was at 01:49 PM ----------
Here is the code I used for FTP...
I need similar thing to be done with ssh, just instead of mget, I need to run queries.
ssh is designed to prevent you from using passwords passed along in plaintext because that is extremely insecure. So does any sane authentication system, like su and sudo.
Could you handle the password in the PHP script itself then, and after the PHP script decides its authorized, connect to the appropriate site with noninteractive SSH keys?
---------- Post updated at 12:06 PM ---------- Previous update was at 12:03 PM ----------
Another method would be editing /etc/ssh/sshd_config in the system you're connecting to to be more lax in its security PasswordAuthentication yes which would allow you to use the PEAR-ssh2 PHP module on your system. See ssh2-connect and related calls.
Could you handle the password in the PHP script itself then, and after the PHP script decides its authorized, connect to the appropriate site with noninteractive SSH keys?
Exactly this is my problem.... How would I authorize users in PHP itself while logging into remote machine? I don't know any other method than ssh.
Also I could not find /etc/ssh/sshd_config in the system I am connecting to. There is sshd_config in /etc/ but I am unable to open it.
Exactly this is my problem.... How would I authorize users in PHP itself while logging into remote machine?
Something like
You don't even need to store the password anywhere For instructions on how to generate these key files and send them to the computer you want to connect to, google passwordless ssh.
Quote:
There is sshd_config in /etc/ but I am unable to open it.
If you don't have root privileges on the system you're connecting to, that won't work.
Hi,
I want to validate ssh connection one after one for multiple servers..... password less keys already setup but now i want to validate if ssh is working fine or not...
I have .sh script like below and i have servers.txt contains all the list of servers
#/bin/bash
for host in $(cat... (3 Replies)
Hey,
I need a script that tries to connect via SSH to a remote server
and that remote server might not be up yet, so retry until succeed
the error message I get if the server is not up yet is:
ssh: connect to host 127.0.0.1 port 40001: Connection refused
any idea of a good way to do it ?
... (5 Replies)
Hi
Through nimadm (alt_disk_install) we done aix os upgrade in 3 lpars from aix 5.3 to aix 6.1. upgrade was successful.
After the upgrade users complained on their ssh keys.
Does upgrading aix version affects the user's ssh keys ? If so please suggest on options to correct them. (1 Reply)
Hello,
I am not sure if I am posting in the right forum.
A website is running on a server with <ip1> in unix. It's written in JSP.
I need to add a link on the page, which will on-clicking ask for username and password to enter into another server <ip2> and gets all the files from a... (1 Reply)
Hi Guys!
I am trying to write a shell script for automated ssh. vairable user and passwd have initialized correctly, but when I use the following it still prompting me for the password.
#!/usr/bin/bash
user='root@10.14.76.225'
passwd='admin'
ssh $user
$passwd
uptime
exit
I... (3 Replies)
Hello there.
I'm fairly new to Linux, but I am connecting via SSH and PuTTY to a remote server, and I am running a fairly heavy MySQL script in a PHP page.
Our connection here is dodgy to say the least and I get continuous disconnections.
My question is, when I get disconnected, does my... (4 Replies)
Hi all, I connect with SSH connection to remote machine in the script and ı want to logout at half of the script then continue to script. If ı write exit in the script it terminates script not SSH connection. How can i do that please help me (1 Reply)
Hi all,
I'm writing a script that chooses the best computer available in an open lab. The script works great except every now and then there is a dead computer in the lab that begins the ssh handshaking, but freezes after the following:
debug1: Offering public key:
When the script happens... (2 Replies)
Hi,
I am new to Shell Scripting. Can anybody help me in writing a Script Which Could Login from a Unix box to a Remote Unix box which accepts the user credentials automatically and display the result for checking the Disk Space Utilisation (Without running any SSH agent). (1 Reply)
Hi. I have a kornshell script that runs on a daily basis as a cron job. Part of what the script does is copy the folder contents from another server to the current server (server where KSH script is running).
I have a scp command, as follows:
scp $REMOTE_HOST:$REMOTE_FILE_DIR/* $TMP_DIR
... (8 Replies)