0

I am able to ssh into my machine once I log in to it, but I am not able to ssh into it on boot without first logging in.

The machine boots, and then it shows the login screen. I want to be able to ssh to the machine without having to actually log in. For example, if my machine is at home, and I am at work, and my machine reboots, today I can't ssh into it until someone logs in. I want to be able to ssh without logging in.

What settings do I need to change so I can ssh on boot without logging in?

Details:

When I try to ssh on boot without logging in i get this response: Permission denied (publickey).

My machine has a wired connection - I am able to ping it on boot, so the issue doesn't seem to be network connectivity. I also checked my network settings, and it says the ethernet connection is available to all users.

After logging in, I am able to ssh to my machine, from local computers and remote computers.

I tried following the advice here (Start SSH automatically on boot) and running: sudo systemctl enable ssh

This did not change anything. On reboot I still couldn't ssh until I logged in.

Then I tried following the advice here (Start ssh server on boot) and running: sudo systemctl enable ssh.socket

On reboot, I couldn't ssh, and it gave me this error: ssh: connect to host HOSTNAME port PORTNUMBER: Connection refused

After logging in, it gave me the same error, so I could no longer ssh even though I had logged into my machine.

So I undid this change by running: sudo systemctl disable ssh.socket

Things work again (after I log in), but not on boot before logging in.

Here's the output from systemctl cat sshd.service:

# /lib/systemd/system/ssh.service
[Unit]
Description=OpenBSD Secure Shell server
After=network.target auditd.service
ConditionPathExists=!/etc/ssh/sshd_not_to_be_run

[Service]
EnvironmentFile=-/etc/default/ssh
ExecStart=/usr/sbin/sshd -D $SSHD_OPTS
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
RestartPreventExitStatus=255
Type=notify

[Install]
WantedBy=multi-user.target
Alias=sshd.service

Here's the output from ssh ubuntu-local -v (note I am using a ssh config file):

$ ssh ubuntu-local -v
OpenSSH_7.4p1, LibreSSL 2.5.0
debug1: Reading configuration data /Users/fakeusername/.ssh/config
debug1: /Users/fakeusername/.ssh/config line 1: Applying options for ubuntu-local
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 20: Applying options for *
debug1: /etc/ssh/ssh_config line 102: Applying options for *
debug1: Connecting to fakehostname.local [aaaa::aaaa:aaaa:aaaa:aaaa%en0] port 2341.
debug1: Connection established.
debug1: identity file /Users/fakeusername/.ssh/id_ed25519 type 4
debug1: key_load_public: No such file or directory
debug1: identity file /Users/fakeusername/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.4
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.2p2 Ubuntu-4ubuntu2.4
debug1: match: OpenSSH_7.2p2 Ubuntu-4ubuntu2.4 pat OpenSSH* compat 0x04000000
debug1: Authenticating to fakehostname.local:2341 as 'testusername'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256@libssh.org
debug1: kex: host key algorithm: ssh-ed25519
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ssh-ed25519 SHA256:asdfasdfasfasdfasdfasdfasdfsadfasfd
debug1: Host '[fakehostname.local]:2341' is known and matches the ED25519 host key.
debug1: Found key in /Users/fakeusername/.ssh/known_hosts:32
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering ED25519 public key: /Users/fakeusername/.ssh/id_ed25519
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).
ptjetty
  • 103

0 Answers0