Can I ssh via public key if there is no home directory on the remote system?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
4
down vote

favorite












I currently have to ssh with user FOO then sudo to user BAR.



I would like to ssh using a public key, but on the remote system there is no home directory for user FOO, so obviously no .ssh/authorized_keys. Where can I put my public key ?



The /home directory is empty, so it seems no home directories are created for any user, and I don't have root on that system.



Thanks.







share|improve this question




















  • Not an answer, just a note: You will need the private key.
    – ctrl-alt-delor
    Feb 8 at 12:32














up vote
4
down vote

favorite












I currently have to ssh with user FOO then sudo to user BAR.



I would like to ssh using a public key, but on the remote system there is no home directory for user FOO, so obviously no .ssh/authorized_keys. Where can I put my public key ?



The /home directory is empty, so it seems no home directories are created for any user, and I don't have root on that system.



Thanks.







share|improve this question




















  • Not an answer, just a note: You will need the private key.
    – ctrl-alt-delor
    Feb 8 at 12:32












up vote
4
down vote

favorite









up vote
4
down vote

favorite











I currently have to ssh with user FOO then sudo to user BAR.



I would like to ssh using a public key, but on the remote system there is no home directory for user FOO, so obviously no .ssh/authorized_keys. Where can I put my public key ?



The /home directory is empty, so it seems no home directories are created for any user, and I don't have root on that system.



Thanks.







share|improve this question












I currently have to ssh with user FOO then sudo to user BAR.



I would like to ssh using a public key, but on the remote system there is no home directory for user FOO, so obviously no .ssh/authorized_keys. Where can I put my public key ?



The /home directory is empty, so it seems no home directories are created for any user, and I don't have root on that system.



Thanks.









share|improve this question











share|improve this question




share|improve this question










asked Feb 8 at 12:21









ccc

211




211











  • Not an answer, just a note: You will need the private key.
    – ctrl-alt-delor
    Feb 8 at 12:32
















  • Not an answer, just a note: You will need the private key.
    – ctrl-alt-delor
    Feb 8 at 12:32















Not an answer, just a note: You will need the private key.
– ctrl-alt-delor
Feb 8 at 12:32




Not an answer, just a note: You will need the private key.
– ctrl-alt-delor
Feb 8 at 12:32










2 Answers
2






active

oldest

votes

















up vote
1
down vote













Assuming your username is testssh:



  • create /etc/ssh/authorized_keys_testssh and put your key there


  • add the following in /etc/ssh/sshd_config



    Match User testssh



    AuthorizedKeysFile /etc/ssh/authorized_keys_%u


and restart sshd. Your user will be able to ssh with his private key.






share|improve this answer
















  • 2




    It's unlikely that this user has the permissions to do that. If they had elevated privileges then they could just give themselves a home directory, no?
    – igal
    Feb 8 at 13:43






  • 1




    indeed, this cannot be achieved without involving the admin (root).
    – tonioc
    Feb 8 at 15:38






  • 2




    But the question specifically states that the user does not have root access.
    – igal
    Feb 8 at 17:02






  • 1




    Thx for the suggestion tonioc, but igal is 100% right. Have very limited permissions on remote machine, which is why I specifically mentioned I don't have root. If I could create files in /etc, I could probably create a directory in /home and just do my stuff in there (create .ssh and .ssh/authrorized_keys)
    – ccc
    Feb 9 at 13:52


















up vote
1
down vote













Short Answer



You probably can't - talk to your sysadmin.




Longer Answer



First of all, the fact that the /home directory is empty (and even if it doesn't exist) doesn't necessarily mean that your user doesn't have a home directory. You can try looking at the value of the HOME environment variable:



$ echo $HOME
/path/to/nonstandard/homedirectory


or use the getent command:



$ getent passwd username
username:*:1001:1001:User Name:/path/to/nonstandard/homedirectory:/bin/bash


If it turns out that your user really does not have a home directory then it still might be possible to use a public key if your server administrator has set a nonstandard location for your authorized_keys file.



Assuming you're using OpenSSH, the location of the authorized_keys file can be specified by the AuthorizedKeysFile keyword in the sshd_config configuration file. Consult the documentation for more information:



  • https://man.openbsd.org/sshd_config#AuthorizedKeysFile

The default value is ~/.ssh/authorized_keys. You'll have to look at the settings in /etc/ssh/sshd_config to see if the default is being over-ridden. Since you don't have root access you'll probably have to ask your system administrator for help if you want to make any changes.



If it turns out that you don't have a home directory, that your system administrator hasn't configured a different location for your authorized_keys file, and you don't have administrative privileges on your machine, then you probably won't be able to use key-based authentication - talk to your sysadmin.






share|improve this answer






















  • Thx. The home points to the nonexistent directory /home/FOO. In fact, /home is 100% empty. No user has a home directory, it seems.
    – ccc
    Feb 9 at 14:04











  • The root user probably has a home directory (it's usually /root). You can check to see if other users have home directories by checking /etc/passwd or using getent (e.g. getent passwd | cut -d: -f6). Anyway, have you asked your sysadmin to create a home directory for you?
    – igal
    Feb 9 at 14:25










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f422790%2fcan-i-ssh-via-public-key-if-there-is-no-home-directory-on-the-remote-system%23new-answer', 'question_page');

);

Post as a guest






























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote













Assuming your username is testssh:



  • create /etc/ssh/authorized_keys_testssh and put your key there


  • add the following in /etc/ssh/sshd_config



    Match User testssh



    AuthorizedKeysFile /etc/ssh/authorized_keys_%u


and restart sshd. Your user will be able to ssh with his private key.






share|improve this answer
















  • 2




    It's unlikely that this user has the permissions to do that. If they had elevated privileges then they could just give themselves a home directory, no?
    – igal
    Feb 8 at 13:43






  • 1




    indeed, this cannot be achieved without involving the admin (root).
    – tonioc
    Feb 8 at 15:38






  • 2




    But the question specifically states that the user does not have root access.
    – igal
    Feb 8 at 17:02






  • 1




    Thx for the suggestion tonioc, but igal is 100% right. Have very limited permissions on remote machine, which is why I specifically mentioned I don't have root. If I could create files in /etc, I could probably create a directory in /home and just do my stuff in there (create .ssh and .ssh/authrorized_keys)
    – ccc
    Feb 9 at 13:52















up vote
1
down vote













Assuming your username is testssh:



  • create /etc/ssh/authorized_keys_testssh and put your key there


  • add the following in /etc/ssh/sshd_config



    Match User testssh



    AuthorizedKeysFile /etc/ssh/authorized_keys_%u


and restart sshd. Your user will be able to ssh with his private key.






share|improve this answer
















  • 2




    It's unlikely that this user has the permissions to do that. If they had elevated privileges then they could just give themselves a home directory, no?
    – igal
    Feb 8 at 13:43






  • 1




    indeed, this cannot be achieved without involving the admin (root).
    – tonioc
    Feb 8 at 15:38






  • 2




    But the question specifically states that the user does not have root access.
    – igal
    Feb 8 at 17:02






  • 1




    Thx for the suggestion tonioc, but igal is 100% right. Have very limited permissions on remote machine, which is why I specifically mentioned I don't have root. If I could create files in /etc, I could probably create a directory in /home and just do my stuff in there (create .ssh and .ssh/authrorized_keys)
    – ccc
    Feb 9 at 13:52













up vote
1
down vote










up vote
1
down vote









Assuming your username is testssh:



  • create /etc/ssh/authorized_keys_testssh and put your key there


  • add the following in /etc/ssh/sshd_config



    Match User testssh



    AuthorizedKeysFile /etc/ssh/authorized_keys_%u


and restart sshd. Your user will be able to ssh with his private key.






share|improve this answer












Assuming your username is testssh:



  • create /etc/ssh/authorized_keys_testssh and put your key there


  • add the following in /etc/ssh/sshd_config



    Match User testssh



    AuthorizedKeysFile /etc/ssh/authorized_keys_%u


and restart sshd. Your user will be able to ssh with his private key.







share|improve this answer












share|improve this answer



share|improve this answer










answered Feb 8 at 12:54









tonioc

1,11457




1,11457







  • 2




    It's unlikely that this user has the permissions to do that. If they had elevated privileges then they could just give themselves a home directory, no?
    – igal
    Feb 8 at 13:43






  • 1




    indeed, this cannot be achieved without involving the admin (root).
    – tonioc
    Feb 8 at 15:38






  • 2




    But the question specifically states that the user does not have root access.
    – igal
    Feb 8 at 17:02






  • 1




    Thx for the suggestion tonioc, but igal is 100% right. Have very limited permissions on remote machine, which is why I specifically mentioned I don't have root. If I could create files in /etc, I could probably create a directory in /home and just do my stuff in there (create .ssh and .ssh/authrorized_keys)
    – ccc
    Feb 9 at 13:52













  • 2




    It's unlikely that this user has the permissions to do that. If they had elevated privileges then they could just give themselves a home directory, no?
    – igal
    Feb 8 at 13:43






  • 1




    indeed, this cannot be achieved without involving the admin (root).
    – tonioc
    Feb 8 at 15:38






  • 2




    But the question specifically states that the user does not have root access.
    – igal
    Feb 8 at 17:02






  • 1




    Thx for the suggestion tonioc, but igal is 100% right. Have very limited permissions on remote machine, which is why I specifically mentioned I don't have root. If I could create files in /etc, I could probably create a directory in /home and just do my stuff in there (create .ssh and .ssh/authrorized_keys)
    – ccc
    Feb 9 at 13:52








2




2




It's unlikely that this user has the permissions to do that. If they had elevated privileges then they could just give themselves a home directory, no?
– igal
Feb 8 at 13:43




It's unlikely that this user has the permissions to do that. If they had elevated privileges then they could just give themselves a home directory, no?
– igal
Feb 8 at 13:43




1




1




indeed, this cannot be achieved without involving the admin (root).
– tonioc
Feb 8 at 15:38




indeed, this cannot be achieved without involving the admin (root).
– tonioc
Feb 8 at 15:38




2




2




But the question specifically states that the user does not have root access.
– igal
Feb 8 at 17:02




But the question specifically states that the user does not have root access.
– igal
Feb 8 at 17:02




1




1




Thx for the suggestion tonioc, but igal is 100% right. Have very limited permissions on remote machine, which is why I specifically mentioned I don't have root. If I could create files in /etc, I could probably create a directory in /home and just do my stuff in there (create .ssh and .ssh/authrorized_keys)
– ccc
Feb 9 at 13:52





Thx for the suggestion tonioc, but igal is 100% right. Have very limited permissions on remote machine, which is why I specifically mentioned I don't have root. If I could create files in /etc, I could probably create a directory in /home and just do my stuff in there (create .ssh and .ssh/authrorized_keys)
– ccc
Feb 9 at 13:52













up vote
1
down vote













Short Answer



You probably can't - talk to your sysadmin.




Longer Answer



First of all, the fact that the /home directory is empty (and even if it doesn't exist) doesn't necessarily mean that your user doesn't have a home directory. You can try looking at the value of the HOME environment variable:



$ echo $HOME
/path/to/nonstandard/homedirectory


or use the getent command:



$ getent passwd username
username:*:1001:1001:User Name:/path/to/nonstandard/homedirectory:/bin/bash


If it turns out that your user really does not have a home directory then it still might be possible to use a public key if your server administrator has set a nonstandard location for your authorized_keys file.



Assuming you're using OpenSSH, the location of the authorized_keys file can be specified by the AuthorizedKeysFile keyword in the sshd_config configuration file. Consult the documentation for more information:



  • https://man.openbsd.org/sshd_config#AuthorizedKeysFile

The default value is ~/.ssh/authorized_keys. You'll have to look at the settings in /etc/ssh/sshd_config to see if the default is being over-ridden. Since you don't have root access you'll probably have to ask your system administrator for help if you want to make any changes.



If it turns out that you don't have a home directory, that your system administrator hasn't configured a different location for your authorized_keys file, and you don't have administrative privileges on your machine, then you probably won't be able to use key-based authentication - talk to your sysadmin.






share|improve this answer






















  • Thx. The home points to the nonexistent directory /home/FOO. In fact, /home is 100% empty. No user has a home directory, it seems.
    – ccc
    Feb 9 at 14:04











  • The root user probably has a home directory (it's usually /root). You can check to see if other users have home directories by checking /etc/passwd or using getent (e.g. getent passwd | cut -d: -f6). Anyway, have you asked your sysadmin to create a home directory for you?
    – igal
    Feb 9 at 14:25














up vote
1
down vote













Short Answer



You probably can't - talk to your sysadmin.




Longer Answer



First of all, the fact that the /home directory is empty (and even if it doesn't exist) doesn't necessarily mean that your user doesn't have a home directory. You can try looking at the value of the HOME environment variable:



$ echo $HOME
/path/to/nonstandard/homedirectory


or use the getent command:



$ getent passwd username
username:*:1001:1001:User Name:/path/to/nonstandard/homedirectory:/bin/bash


If it turns out that your user really does not have a home directory then it still might be possible to use a public key if your server administrator has set a nonstandard location for your authorized_keys file.



Assuming you're using OpenSSH, the location of the authorized_keys file can be specified by the AuthorizedKeysFile keyword in the sshd_config configuration file. Consult the documentation for more information:



  • https://man.openbsd.org/sshd_config#AuthorizedKeysFile

The default value is ~/.ssh/authorized_keys. You'll have to look at the settings in /etc/ssh/sshd_config to see if the default is being over-ridden. Since you don't have root access you'll probably have to ask your system administrator for help if you want to make any changes.



If it turns out that you don't have a home directory, that your system administrator hasn't configured a different location for your authorized_keys file, and you don't have administrative privileges on your machine, then you probably won't be able to use key-based authentication - talk to your sysadmin.






share|improve this answer






















  • Thx. The home points to the nonexistent directory /home/FOO. In fact, /home is 100% empty. No user has a home directory, it seems.
    – ccc
    Feb 9 at 14:04











  • The root user probably has a home directory (it's usually /root). You can check to see if other users have home directories by checking /etc/passwd or using getent (e.g. getent passwd | cut -d: -f6). Anyway, have you asked your sysadmin to create a home directory for you?
    – igal
    Feb 9 at 14:25












up vote
1
down vote










up vote
1
down vote









Short Answer



You probably can't - talk to your sysadmin.




Longer Answer



First of all, the fact that the /home directory is empty (and even if it doesn't exist) doesn't necessarily mean that your user doesn't have a home directory. You can try looking at the value of the HOME environment variable:



$ echo $HOME
/path/to/nonstandard/homedirectory


or use the getent command:



$ getent passwd username
username:*:1001:1001:User Name:/path/to/nonstandard/homedirectory:/bin/bash


If it turns out that your user really does not have a home directory then it still might be possible to use a public key if your server administrator has set a nonstandard location for your authorized_keys file.



Assuming you're using OpenSSH, the location of the authorized_keys file can be specified by the AuthorizedKeysFile keyword in the sshd_config configuration file. Consult the documentation for more information:



  • https://man.openbsd.org/sshd_config#AuthorizedKeysFile

The default value is ~/.ssh/authorized_keys. You'll have to look at the settings in /etc/ssh/sshd_config to see if the default is being over-ridden. Since you don't have root access you'll probably have to ask your system administrator for help if you want to make any changes.



If it turns out that you don't have a home directory, that your system administrator hasn't configured a different location for your authorized_keys file, and you don't have administrative privileges on your machine, then you probably won't be able to use key-based authentication - talk to your sysadmin.






share|improve this answer














Short Answer



You probably can't - talk to your sysadmin.




Longer Answer



First of all, the fact that the /home directory is empty (and even if it doesn't exist) doesn't necessarily mean that your user doesn't have a home directory. You can try looking at the value of the HOME environment variable:



$ echo $HOME
/path/to/nonstandard/homedirectory


or use the getent command:



$ getent passwd username
username:*:1001:1001:User Name:/path/to/nonstandard/homedirectory:/bin/bash


If it turns out that your user really does not have a home directory then it still might be possible to use a public key if your server administrator has set a nonstandard location for your authorized_keys file.



Assuming you're using OpenSSH, the location of the authorized_keys file can be specified by the AuthorizedKeysFile keyword in the sshd_config configuration file. Consult the documentation for more information:



  • https://man.openbsd.org/sshd_config#AuthorizedKeysFile

The default value is ~/.ssh/authorized_keys. You'll have to look at the settings in /etc/ssh/sshd_config to see if the default is being over-ridden. Since you don't have root access you'll probably have to ask your system administrator for help if you want to make any changes.



If it turns out that you don't have a home directory, that your system administrator hasn't configured a different location for your authorized_keys file, and you don't have administrative privileges on your machine, then you probably won't be able to use key-based authentication - talk to your sysadmin.







share|improve this answer














share|improve this answer



share|improve this answer








edited Feb 9 at 14:27

























answered Feb 8 at 12:46









igal

4,820930




4,820930











  • Thx. The home points to the nonexistent directory /home/FOO. In fact, /home is 100% empty. No user has a home directory, it seems.
    – ccc
    Feb 9 at 14:04











  • The root user probably has a home directory (it's usually /root). You can check to see if other users have home directories by checking /etc/passwd or using getent (e.g. getent passwd | cut -d: -f6). Anyway, have you asked your sysadmin to create a home directory for you?
    – igal
    Feb 9 at 14:25
















  • Thx. The home points to the nonexistent directory /home/FOO. In fact, /home is 100% empty. No user has a home directory, it seems.
    – ccc
    Feb 9 at 14:04











  • The root user probably has a home directory (it's usually /root). You can check to see if other users have home directories by checking /etc/passwd or using getent (e.g. getent passwd | cut -d: -f6). Anyway, have you asked your sysadmin to create a home directory for you?
    – igal
    Feb 9 at 14:25















Thx. The home points to the nonexistent directory /home/FOO. In fact, /home is 100% empty. No user has a home directory, it seems.
– ccc
Feb 9 at 14:04





Thx. The home points to the nonexistent directory /home/FOO. In fact, /home is 100% empty. No user has a home directory, it seems.
– ccc
Feb 9 at 14:04













The root user probably has a home directory (it's usually /root). You can check to see if other users have home directories by checking /etc/passwd or using getent (e.g. getent passwd | cut -d: -f6). Anyway, have you asked your sysadmin to create a home directory for you?
– igal
Feb 9 at 14:25




The root user probably has a home directory (it's usually /root). You can check to see if other users have home directories by checking /etc/passwd or using getent (e.g. getent passwd | cut -d: -f6). Anyway, have you asked your sysadmin to create a home directory for you?
– igal
Feb 9 at 14:25












 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f422790%2fcan-i-ssh-via-public-key-if-there-is-no-home-directory-on-the-remote-system%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay