Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am using Sequel Pro to connect to a remote database. Normally, when I SSH in, I have to run sudo su before I can access the database. So when I put in my normal SSH credentials into Sequel Pro, it comes back with an error that I don't have the rights to access the DB server (just like I get an error when I try to connect from the command line without sudo su).

So is there a way to sudo connect to a remote server?

share|improve this question
    
so, you want to connect to a remote mysql-instance over ssh? –  akira Jul 11 '11 at 18:29
    
so, what is the error you get when you ssh into the machine with a normal user, and invoke mysql -u <username> -p, where the username is the database username, as set in SequelPro, and the password is the one from Sequel pro? –  Sunny Jul 11 '11 at 18:48
    
Actually, I'm thinking the issue may be that I'm not able to SSH in because of public key authentication, even though the notes for SequelPro says that it will use the same keys that are used for Terminal. –  Anthony Jul 11 '11 at 20:51
    
Sorry, on even further investigation, it seems the issue is with connecting via a socket after SSHing in, which I'm not seeing as an option. –  Anthony Jul 11 '11 at 20:59
    
if you want a good answer: describe better what the situation is on the server side and on the client side. so far we are just guessing that you are trying to access a mysqld running via a socket (and you normally do not have the permissions to access that socket) –  akira Jul 12 '11 at 7:14

2 Answers 2

Please! Don't allow root logins via SSH!

Instead, edit your sudoers file to allow the command(s) you need to execute as the user you're logging in as--this is precisely why sudo exists! Then simply pre-pend the word 'sudo' to your remote command.

Example /etc/sudoers file:

myuser ALL=(root) NOPASSWD: /path/to/my/command --my --argument --list

Then your SSH command:

ssh myuser@remotehost "sudo /path/to/my/command --my --argument --list"

man sudoers and man ssh will provide additional details.

share|improve this answer
    
thats more comment to @The White Phoenix than an answer to the problem. OP seems to want to tunnel a connection from a mysql-gui to a mysql-daemon listening on a socket. –  akira Jul 12 '11 at 8:45
    
I think I answered the question... I think you may be right, though, that the OP asked the wrong question. –  Flimzy Jul 12 '11 at 8:47

Perhaps just enable remote logins as root, set a root password and then ssh as 'root'. This is generally discouraged as it is considered insecure to allow root logins over ssh. There are however various steps you can take to improve security about allowing this kind of login:

  1. Only allow root logins that use both passwords and key authentication
  2. Only allow root logins from certain known/trusted IP addresses
  3. Change the root username to something unique (not totally sure how easily this can be done)

This ServerFault question has a few more ssh security suggestions.

A much more 'secure' solution is to create a remote system account that only has permission to do the things you need to do. This obviously requires some reconfiguration on the machine you're logging in to and you don't say if that's an option for you.

share|improve this answer
    
Indeed as Flimzy says below, root logins over ssh are not generally considered a good idea.. And if the question asker really is only asking about port forwarding, then enabling root logins for that is an entertainingly illadvised idea. Still, I wanted to post that this is an option as I think there can be legitimate cases for this. Just be very careful. And try other solutions first ;) –  Doc Jul 12 '11 at 15:38

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.