Solved

Ssh and sudo

Posted on 2012-04-11
6
826 Views
Last Modified: 2012-04-16
I have rsa keys setup between server A and server B.  server A needs to ssh into server B without a password.

Problem is that server B is setup to login as sudo without password.  So in order to get into server B, I have to log into a personal account, then do a "sudo su - accountname".  I am not given access to a password - it logs in automatically.

Realize this is probably the stupidest thing you ever heard but it is what it is.

I can't get ssh to log into server B without prompting for password even though I've correctly setup public, private keys (tested on a normal server with username and password authentication.)

Is this because of sudo for server B messes up things?  I read somewhere if you don't have password set for a server, ssh without password won't work.
0
Comment
Question by:lcor
  • 3
  • 2
6 Comments
 
LVL 31

Assisted Solution

by:farzanj
farzanj earned 250 total points
ID: 37833359
If ssh key mechism is setup, passwords are irrelevent.
Second if I understand you correctly , did you try:

ssh serverB "sudo su accountname -c ls"

Does this work for you?
0
 

Author Comment

by:lcor
ID: 37834081
farzanj, I'm experiencing technical difficulties at this time.  As soon as I can, I'll try the ssh with sudo.
0
 
LVL 31

Expert Comment

by:farzanj
ID: 37834088
No problem :)
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

Author Comment

by:lcor
ID: 37838312
farzanj, I tried your command and it still prompts for password.
I checked permissions on .ssh and authorized keys and they look good.
server A can successfully log into server C with the server A's public key in authorized_keys file
However server A is Solaris, server B is Linux, server C is Solaris
server A and server C run the same version of ssh
server A and server B run different versions of ssh
0
 

Author Comment

by:lcor
ID: 37838463
I also tried to setup keys between server A and server D.  They are both Linux and have sudo logins.  It doesn't work.  I seriously think it has something to do with sudo because the 2 Solaris servers have normal username and password logins but the Linux servers don't.
0
 
LVL 28

Accepted Solution

by:
serialband earned 250 total points
ID: 37852189
You should be able to log in to root with ssh keys even without a password.  I log in all the time with ssh keys to accounts without passwords.  The settings to deny root login should be in your sshd.config.  You just need to set PermitRootLogin to yes in sshd.config

PermitRootLogin yes

Open in new window


I do this on ubuntu and osx systems, which both require sudo for root and block root password login by default.
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now