so I am looking to set up ssh private/public keys between two servers, for use with sftp (and ultimately lftp using sftp - but one step at a time).
I have created the private and public keys, and found that in order to use them, the private key must be owned and only readable by the user connecting.
The problem is, the user I am connecting as doesn't have a /home/ directory on either server (and only exists on the remote server), so when I try to chown
, I get chown: invalid user: {userName}
- because it doesn't exist locally.
Can anyone suggest a way around this?
--Edit--
I used getent passwd
on both servers, and found that the user only exists on the server I'm sftp
ing to. So when I connect as that user (sftp weirdUser@remoteHost
), how can I do this using private/public keys?
you need to create the user SSH private/public key is just another method of authentication instead of password authentication.
So you need to create the user that is allowed to use the public private key pair http://www.tecmint.com/add-users-in-linux/
Create the user then you can CHOWN to that user.
You need a
~/.ssh/config
file on your local server that will associate your key with the user on the remote server such as:If you want to create a unique key just for weirduser@yourremoteserver use the
-f
option on ssh-keygen:and replace the IdentifyFile line in the
~/.ssh/config
file with:Whichever key you decide to use (the default id_rsa or weirduser), you'll need the contents of the corresponding .pub file inserted into weirduser's
authorized_keys
on the remote server. After you have your config file setup, try (it'll prompt for the remote password then copy the .pub file to the correctauthorized_keys
):(Or you could do this manually)