Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
ssh as different user
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
ppeetteerr
n00b
n00b


Joined: 19 Nov 2007
Posts: 58

PostPosted: Fri May 30, 2008 6:13 pm    Post subject: ssh as different user Reply with quote

Ok so my username on my home computer is peter. My user name on host.com is ppeetteerr. In the past I've done
Code:
 ssh ppeetteerr@host.com
or when I'm feeling adventurous
Code:
 ssh -l ppeetteerr host.com


My question is: is there a way to change my default user name when I ssh. So I can just ssh host.com and it logs me in as ppeetteerr?
Back to top
View user's profile Send private message
Aleksi Halkola
n00b
n00b


Joined: 02 Aug 2005
Posts: 21

PostPosted: Fri May 30, 2008 6:27 pm    Post subject: Reply with quote

you can do that in ~/.ssh/config. Just add teh following

Host host.com IP
HostName full.host.name.com
User ppeetteerr
Back to top
View user's profile Send private message
think4urs11
Bodhisattva
Bodhisattva


Joined: 25 Jun 2003
Posts: 6659
Location: above the cloud

PostPosted: Fri May 30, 2008 6:27 pm    Post subject: Re: ssh as different user Reply with quote

Code:
cat ~/.ssh/config
Host schnickschnack
 HostName host.com
 User ppeetteerr
me@box $ ssh schnickschnack

_________________
Nothing is secure / Security is always a trade-off with usability / Do not assume anything / Trust no-one, nothing / Paranoia is your friend / Think for yourself
Back to top
View user's profile Send private message
mimosinnet
l33t
l33t


Joined: 10 Aug 2006
Posts: 717
Location: Barcelona, Spain

PostPosted: Mon Jun 09, 2008 6:12 pm    Post subject: Reply with quote

This is somehow related. I have a user (joanet) and I am the root in the same box. I ssh to the same external boxes, so I thought I could make a symbolic link and root could use joanet configuration:
Code:
# ln -s /home/joanet/.ssh /root/.ssh

Code:
# ls -lisah /root
14417927    0 lrwxrwxrwx  1 root root   17  9 jun 19:46 .ssh -> /home/joanet/.ssh

When I try to ssh from root:
# ssh mimosinnet
I get the following message:
Code:
Bad owner or permissions on /root/.ssh/config

I understand the message: I am trying to ssh from root and the file owner is joanet:
Code:
# ls -lisah /root/.ssh/config
11337740 4,0K -rw------- 1 joanet joanet 359  9 jun 20:04 /root/.ssh/config

This is my /root/.ssh/config
Code:
# cat /root/.ssh/config
Host mimosinnet
        User mimosinnet
        IdentityFile ~/.ssh/id_dsa
        ForwardX11 yes
        Compression yes
        ForwardX11Trusted yes


If I copy my joanet configuration to root, I have joanet ssh configuration working in root:
Code:
cp -r /home/joanet/.ssh .


Is there a possibility to use symbolic links to not have to maintain two similar ssh configurations (joanet and root)?

Thanks!
Back to top
View user's profile Send private message
Dieter@be
Guru
Guru


Joined: 03 Apr 2005
Posts: 314
Location: Wetteren, Belgium

PostPosted: Mon Jun 09, 2008 6:16 pm    Post subject: Reply with quote

afaik the owner of the ssh config must always be the user itself
_________________
Nothing beats a ride on the Gentoo learning curve.
2 Gentoo Linux boxes - 2 Arch Linux boxes - Love all four
Say no to i386 binaries! -- Adopt an unanswered topic
Back to top
View user's profile Send private message
mimosinnet
l33t
l33t


Joined: 10 Aug 2006
Posts: 717
Location: Barcelona, Spain

PostPosted: Mon Jun 09, 2008 7:44 pm    Post subject: Reply with quote

Dieter@be wrote:
afaik the owner of the ssh config must always be the user itself


Good to know! This leads me towards finding another strategy. Thanks a lot for the answer! :-)
Back to top
View user's profile Send private message
infinite1der
n00b
n00b


Joined: 31 Jan 2006
Posts: 52
Location: Atlanta, GA

PostPosted: Mon Jun 09, 2008 9:12 pm    Post subject: Reply with quote

mimosinnet wrote:
Dieter@be wrote:
afaik the owner of the ssh config must always be the user itself


Good to know! This leads me towards finding another strategy. Thanks a lot for the answer! :-)


See also sshd_config: StrictModes
_________________
----------------------
James A. Thornton
Atlanta, GA

How To Ask Questions the Smart Way
Back to top
View user's profile Send private message
mimosinnet
l33t
l33t


Joined: 10 Aug 2006
Posts: 717
Location: Barcelona, Spain

PostPosted: Wed Jun 11, 2008 3:39 am    Post subject: Reply with quote

infinite1der wrote:
See also sshd_config: StrictModes


Thanks very much for the tip. I have tried StrictModes with the abovementioned configuration (symbolic link of .ssh from root to user) and still unable to connect:
Code:
# grep StrictModes /etc/ssh/sshd_config
StrictModes no
# ssh mimosinnet
Bad owner or permissions on /root/.ssh/config


These are the permissions of the config file:
Code:
11339658 4,0K -rw-------  1 joanet joanet  466 11 jun 05:12 config


Nevertheless, if I change the owner and permissions of the config file (it does not work if I make the file writtable for the group):
Code:
11339658 4,0K -rw-r-----  1 root   users   466 11 jun 05:12 config


I am able to log from root and the user. :D

Great! Wonderful! Thanks a lot!

Update: Nevertheless, this happens independently of the value of StrictModes. :!: :?:
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum