Can I use Cygwin via ssh without logging into Windows account for first time?

1

When creating a new Windows 8.1 user account, you normally have to logout your current account and log back in as the new user. When this happens Windows start setting up your home directory and does a number of other things. (I don't know what!)

But since I have already installed Cygwin and ssh using another account, I just want to add an extra SSH-only account, without all the regular Windows garbage folders.

So by using the native Windows command line tools net, editrights and wmic etc, I can add users and passwords. So is it possible to setup a functioning Cygwin user to ssh into this machine?

Cygwin usually like to start some scripts (which?) when running the Cygwin shell for the first time. So how could I accomplish the same thing by logging in via ssh (from another local account)?

PS. After writing out this question I realize that it kind of boil down to understanding what windows does when you login for the first time, and if (whatever it does) this is really necessary, for a functioning account.

not2qubit

Posted 2014-03-05T17:42:20.290

Reputation: 1 234

Answers

0

This was piece of cake! Never thought it would work. Just create a new Windows user account, as normal. Let's call it "xxxx" for simplicity, and make sure to give it Administration privileges. Then open a Cygwin shell by running it as Administrator. Check your account creation with:

net user xxxx

Now execute the following:

mkpasswd.exe -l -u xxxx >>/etc/passwd
net stop sshd
net start sshd

Now go to your external computer and try to connect via SSH to your new user account:

ssh -2 xxxx@<local-pc-ip-address>

Bam! You're in, and Cygwin will automatically create the home directory and copies all the skeleton files for ".bashrc" etc. You don't even need to mess with any ssh files.

Could not chdir to home directory /home/xxxx: No such file or directory
Copying skeleton files.
These files are for the users to personalise their cygwin experience.
They will never be overwritten nor automatically updated.

`./.bashrc' -> `/home/xxxx//.bashrc'
`./.bash_profile' -> `/home/xxxx//.bash_profile'
`./.inputrc' -> `/home/xxxx//.inputrc'
`./.profile' -> `/home/xxxx//.profile'

PS. This assumes you have already setup a working SSHd on your normal windows account.

not2qubit

Posted 2014-03-05T17:42:20.290

Reputation: 1 234

0

(this would be a comment if I had the rep for it)

This may only be anecdotal, but the last time I used OpenSSH from within Cygwin (probably 2001), I was only able to log into SSH as the currently logged in Windows user.

Chris S

Posted 2014-03-05T17:42:20.290

Reputation: 71