Permissions+default directory in openssh on ubuntu

Posted on 2013-01-27
Last Modified: 2013-02-01
I have a pretty basic ubuntu system running in a vm to do open-ssh.  By default each user that gets in via sftp goes to /home/username.  I need to change a user to go to a different directory when logging in.  Note that this user has no password, just a private key (so its authenticating with username+private key).  I need the user bob to default to the /home/homer directory.  I change this by nano /etc/passwd and changing the default but then when user chuck tries to login it doesnt work - says server refused our connection, change it back to /home/bob and it works fine.  Bob does have all access to /home/homeward...he can write files to that directory, change to that directory, and delete files from the directory so not sure why he cant go to that directory by default.
Using winscp to connect (windows machine) and you can specify the local and remote directories - doing this WILL work and allow him to "default" into the /home/homer directory, but I think winscp just logs in then changes directories for him right away (instead of the actual server putting him in that folder which is what I need).
I tried doing it via a group too - still no luck
Question by:rhwimmers
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
LVL 78

Expert Comment

ID: 38824461
Sftp is part of ssh and is directing the user to their home directory by default.

You could use usermod to alter the home directory thus altering where the user will end up upon logon.
I think winscp includes the option to specify the path /home/homeward rather than relying on the default.

Author Comment

ID: 38824553
What command would that be?
LVL 78

Expert Comment

ID: 38824573
Not clear which point from my comment you want addressed in this response.
usermod -d /home/homeward homer
this will also affect the users ssh login which will now get them started at /home/homeward ( you could use .login, .profile, .bash_profile .bashrc to cd to a different directory) but cd ~homer wil always go to where the home directory is pointing within passwd.

I think winscp has the option prior to the connection for the specification of the remote directory which you could use /home/homeward
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 38825017
Still get the same thing "server refused our key" - that is the winscp error I get anytime I try to change the user homer to get into /home/homeward

Author Comment

ID: 38825040
Seems like no matter what I do with usermod -d or editing the /etc/passwd to change the path of the user, I cannot login with the user unless its set to his default /home/homer.  As mentioned earlier - login with username and a key file - the key file has nothing to do with the location right, its just for authentication purposes - just strange that as soon as I change the directory it fails as if its an auth issue.  And again, once logged in I CAN access these directories I am trying to have the user land in by default

server refused our key
authentication failed is the error I get

Accepted Solution

rhwimmers earned 0 total points
ID: 38825160
Ran across this article which solved my issue.  The default is store the key in an encrypted (hidden) folder (.ssh) so moving that elsewhere did the trick.

Author Closing Comment

ID: 38843112
Resolution in link

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Hello to you all, I hear of many people congratulate AWS (Amazon Web Services) on how easy it is to spin up and create new EC2 (Elastic Compute Cloud) instances, but then fail and struggle to connect to them using simple tools such as SSH (Secure…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

728 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