Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am fairly familiar with computers and web stuff but this is a bit out of my comfort zone.

I have a shell script (.sh file) I want to run in a Linux server I have one site hosted (the script is a backup script for a CMS I have installed on that server), but I have no clue on how to do it.

Going through cpanel the only relevant thing I found was the SSH/Shell Access menu, and that prompts me to generate some key which I reckon should be used in a local software or something to connect to that server from my desktop, but I have no idea on what to do, where to go from here. I also heard something about Putty or whatever it is to use that same key but I opened that software and I am completely clueless.

Pardon my extreme ignorance in the subject, also I hope this is the indicated Stack Exchange to ask this question.

share|improve this question

1 Answer 1

Having never used CPanel, I could not be 100% sure of the specifics, but there is fairly clear documentation on CPanel's website. The essence of it is you generate a key pair, and use CPanel to set what user accounts this key pair gives you access to. Keys come in two parts, the public half (utilized on the CPanel managed server) and the private half which you use in conjunction with Putty. It looks like you create a key and then download the private half afterwards. It is considered a security risk if CPanel keeps the private half of the key pair, and you are probably better using a partner tool to putty called Puttygen. This will allow you to generate the private/public pair, and then you can use CPanel to upload ("import") the public half and assign what access you require.

On creating a new connection with Putty, you then put in the server details and on the settings pain on the left expand SSH (under Connection), select Auth and then click Browse... to locate the private part of the key pair you generated with Puttygen or cpanel. Save the settings and then you should be able to connect to the server. At this point you will get the shell where you can run your backup shell script.

The execution of the shell command is a simple case of /path/to/shell_command.sh if it set executable with chmod u+x /path/to/shell_command.sh. If you get weird errors, it may not have a shebang, in which case you might have to run it as /bin/sh /path/to/shell_command.sh or /bin/bash /path/to/shell_command.sh depending on what shell it was written for.

share|improve this answer
    
I have followed most of that and got to the point where I loaded the private key file and Ip onto putty but when I try to connect I get the message: Network Error: Connection Refused. So I must be missing some setting. Keep in mind Im using a shared host so I'm not sure if that has any relevance to the case. –  spacing Sep 8 '13 at 15:55
    
You will need to start an ssh server (usually sshd, and also make sure your firewall allows connection to it on port 22). docs.cpanel.net/twiki/bin/view/AllDocumentation/WHMDocs/… –  Drav Sloan Sep 8 '13 at 15:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.