Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #172704

Re: sending authorized_keys to localhost from an account being created with adduser --disabled-password [was] Re: Need a tutorial

From Greg Wooledge <wooledg@eeg.ccf.org>
Newsgroups linux.debian.user
Subject Re: sending authorized_keys to localhost from an account being created with adduser --disabled-password [was] Re: Need a tutorial
Date 2016-09-23 15:00 +0200
Message-ID <skyf8-3M0-25@gated-at.bofh.it> (permalink)
References <sjQxs-1Ea-15@gated-at.bofh.it> <sjSzf-2R4-25@gated-at.bofh.it> <skegq-8a2-37@gated-at.bofh.it> <skg8z-Rq-67@gated-at.bofh.it> <skxVM-3F6-17@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Fri, Sep 23, 2016 at 12:31:00PM +0000, Stephan Beck wrote:
> I have created a new user account with
> adduser --disabled-password
> What do I want to do?
> I'd like to login to this account "test" from my normal user account by
> ssh via pubkey authentication. My (normal) user account has its keys
> generated and properly deposited on localhost. I logged into the account
> "test" via su - test, creating a keypair. Fine.

Typically, you want to create the keypair as the user on the machine which
will be the client.  This way the private key never has to be touched,
moved, looked at, etc.

So, you want to ssh
FROM user "stephan" on this machine
TO   user "test"    on this (same) machine

The private key needs to reside in ~stephan/.ssh/ where the client will
see it.

The public key needs to be concatenated into ~test/.ssh/authorized_keys
where the server will see it.

> How do I get this public key onto localhost?

Trick question.  You are already on the correct machine.  You just need
to have everything in the correct places (files/directories) with the
correct ownerships.

> I mean, I can create an authorized_keys file manually, copying the
> public key into this authorized_keys file, but it's still in the user's
> directory where it has been generated, it needs to be sent (or get
> somehow) to localhost.

As user stephan:

stephan@hostname:~$ ssh-keygen

As user root:

stephan@hostname:~$ sudo mkdir -p ~test/.ssh
stephan@hostname:~$ sudo sh -c 'cat ~stephan/.ssh/id_rsa.pub >> ~test/.ssh/authorized_keys'
stephan@hostname:~$ sudo chown test ~test/.ssh ~test/.ssh/authorized_keys
stephan@hostname:~$ sudo chmod 700 ~test/.ssh
stephan@hostname:~$ sudo chmod 600 ~test/.ssh/authorized_keys

(Of course, if you prefer you could just obtain a root shell and then run
all of the commands without sudo.)

As user stephan, to test that it works:

stephan@hostname:~$ ssh test@localhost id

If your username isn't actually "stephan", substitute accordingly.

Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Need a tutorial Gene Heskett <gheskett@shentel.net> - 2016-09-21 16:20 +0200
  Re: Need a tutorial Greg Wooledge <wooledg@eeg.ccf.org> - 2016-09-21 16:30 +0200
    Re: Need a tutorial Gene Heskett <gheskett@shentel.net> - 2016-09-21 22:40 +0200
      Re: Need a tutorial Lars Noodén <lars.nooden@gmail.com> - 2016-09-22 09:50 +0200
        Re: Need a tutorial <tomas@tuxteam.de> - 2016-09-22 10:50 +0200
        Re: Need a tutorial Gene Heskett <gheskett@shentel.net> - 2016-09-22 13:20 +0200
          Re: Need a tutorial <tomas@tuxteam.de> - 2016-09-22 14:10 +0200
            Re: Need a tutorial Gene Heskett <gheskett@shentel.net> - 2016-09-22 18:00 +0200
              Re: Need a tutorial Lars Noodén <lars.nooden@gmail.com> - 2016-09-22 18:10 +0200
                Re: Need a tutorial Gene Heskett <gheskett@shentel.net> - 2016-09-22 18:40 +0200
          Re: Need a tutorial Lars Noodén <lars.nooden@gmail.com> - 2016-09-22 14:10 +0200
            Re: Need a tutorial Gene Heskett <gheskett@shentel.net> - 2016-09-22 18:20 +0200
              Re: Need a tutorial davidson@freevolt.org - 2016-09-23 05:10 +0200
    Re: Need a tutorial Jude DaShiell <jdashiel@panix.com> - 2016-09-22 15:50 +0200
      Re: Need a tutorial Gene Heskett <gheskett@shentel.net> - 2016-09-22 18:20 +0200
  Re: Need a tutorial <tomas@tuxteam.de> - 2016-09-21 18:30 +0200
    Re: Need a tutorial Gene Heskett <gheskett@shentel.net> - 2016-09-21 22:50 +0200
    Re: Need a tutorial Stephan Beck <sbeck@secure.mailbox.org> - 2016-09-22 17:40 +0200
      Re: Need a tutorial Greg Wooledge <wooledg@eeg.ccf.org> - 2016-09-22 17:50 +0200
        Re: Need a tutorial Stephan Beck <sbeck@secure.mailbox.org> - 2016-09-22 18:20 +0200
      Re: Need a tutorial Stephan Beck <sbeck@secure.mailbox.org> - 2016-09-22 18:10 +0200
      Re: Need a tutorial "Thomas Schmitt" <scdbackup@gmx.net> - 2016-09-22 18:20 +0200
        Re: Need a tutorial Greg Wooledge <wooledg@eeg.ccf.org> - 2016-09-22 18:20 +0200
          Re: Need a tutorial "Thomas Schmitt" <scdbackup@gmx.net> - 2016-09-22 18:30 +0200
            Re: Need a tutorial Stephan Beck <sbeck@secure.mailbox.org> - 2016-09-22 20:10 +0200
            Re: Need a tutorial Stephan Beck <stebe@mailbox.org> - 2016-09-22 20:30 +0200
        Re: Need a tutorial Stephan Beck <sbeck@secure.mailbox.org> - 2016-09-22 19:00 +0200
      Re: Need a tutorial <tomas@tuxteam.de> - 2016-09-22 19:40 +0200
        sending authorized_keys to localhost from an account being created  with adduser --disabled-password [was] Re: Need a tutorial Stephan Beck <sbeck@secure.mailbox.org> - 2016-09-23 14:40 +0200
          Re: sending authorized_keys to localhost from an account being created with adduser --disabled-password [was] Re: Need a tutorial Greg Wooledge <wooledg@eeg.ccf.org> - 2016-09-23 15:00 +0200
            Re: sending authorized_keys to localhost from an account being  created with adduser --disabled-password [was] Re: Need a tutorial Stephan Beck <sbeck@secure.mailbox.org> - 2016-09-23 16:20 +0200
              Re: sending authorized_keys to localhost from an account being  created with adduser --disabled-password [was] Re: Need a tutorial Stephan Beck <sbeck@secure.mailbox.org> - 2016-09-23 16:20 +0200
            Re: sending authorized_keys to localhost from an account being  created with adduser --disabled-password [was] Re: Need a tutorial Stephan Beck <sbeck@secure.mailbox.org> - 2016-09-23 22:30 +0200
          RESOLVED Re: sending authorized_keys to localhost from an account  being created with adduser --disabled-password [was] Re: Need a tutorial Stephan Beck <sbeck@secure.mailbox.org> - 2016-09-23 15:10 +0200
            Re: RESOLVED Re: sending authorized_keys to localhost from an account  being created with adduser --disabled-password [was] Re: Need a tutorial Stephan Beck <sbeck@secure.mailbox.org> - 2016-09-23 16:00 +0200
          Re: sending authorized_keys to localhost from an account being  created with adduser --disabled-password [was] Re: Need a tutorial <tomas@tuxteam.de> - 2016-09-23 15:20 +0200
            Re: sending authorized_keys to localhost from an account being  created with adduser --disabled-password [was] Re: Need a tutorial Stephan Beck <sbeck@secure.mailbox.org> - 2016-09-23 18:50 +0200
              Re: sending authorized_keys to localhost from an account being  created with adduser --disabled-password [was] Re: Need a tutorial <tomas@tuxteam.de> - 2016-09-24 16:10 +0200
  Re: Need a tutorial Dominique Dumont <dod@debian.org> - 2016-09-22 17:30 +0200
    Re: Need a tutorial Gene Heskett <gheskett@shentel.net> - 2016-09-22 18:40 +0200
      Re: Need a tutorial Greg Wooledge <wooledg@eeg.ccf.org> - 2016-09-22 19:00 +0200
        Re: Need a tutorial Bob Bernstein <poobah@ruptured-duck.com> - 2016-09-22 20:10 +0200
          Re: Need a tutorial "Thomas Schmitt" <scdbackup@gmx.net> - 2016-09-22 21:00 +0200
      Re: Need a tutorial Lars Noodén <lars.nooden@gmail.com> - 2016-09-22 19:10 +0200
      Re: Need a tutorial Dominique Dumont <dod@debian.org> - 2016-09-22 20:20 +0200
        Re: Need a tutorial Greg Wooledge <wooledg@eeg.ccf.org> - 2016-09-22 20:40 +0200
          Re: Need a tutorial Dominique Dumont <dod@debian.org> - 2016-09-22 20:50 +0200
        Re: Need a tutorial Gene Heskett <gheskett@shentel.net> - 2016-09-23 04:30 +0200
          Re: Need a tutorial Dominique Dumont <dod@debian.org> - 2016-09-23 09:20 +0200

csiph-web