Raspbian headless ssh (sshswitch.service) file not working
I just downloaded and wrote the Raspbian Stretch headless image to a micro SD card. I added a DHCP configuration to give the ethernet adapter a 10.0.0.254 address. I then gave my desktop PC's ethernet adapter an address of 10.0.0.2 and connected the PC to the raspberry pi with an ethernet cable.
I tested that I am able to ping the raspberry pi on 10.0.0.254 so I know I'm able to communicate with it.
I then followed the instructions in item #3 of the remote access readme by placing a single empty file named ssh in the root of the boot partition. I mounted this partition on a linux system and verified it contains all the raspbian boot files (such as cmdline.txt).
When I put the SD card back into the pi and boot, the ssh file is not removed and I always get a connection refused message when attempting to ssh into the pi. Any clue what's going wrong? I used the headless image and this method of access to avoid using a separate monitor and keyboard so the fact that this isn't working is kind of a pain.
sshd raspbian
|
show 1 more comment
I just downloaded and wrote the Raspbian Stretch headless image to a micro SD card. I added a DHCP configuration to give the ethernet adapter a 10.0.0.254 address. I then gave my desktop PC's ethernet adapter an address of 10.0.0.2 and connected the PC to the raspberry pi with an ethernet cable.
I tested that I am able to ping the raspberry pi on 10.0.0.254 so I know I'm able to communicate with it.
I then followed the instructions in item #3 of the remote access readme by placing a single empty file named ssh in the root of the boot partition. I mounted this partition on a linux system and verified it contains all the raspbian boot files (such as cmdline.txt).
When I put the SD card back into the pi and boot, the ssh file is not removed and I always get a connection refused message when attempting to ssh into the pi. Any clue what's going wrong? I used the headless image and this method of access to avoid using a separate monitor and keyboard so the fact that this isn't working is kind of a pain.
sshd raspbian
 
 
 
 
 
 
 I suspect the HDMI output will still show a login prompt... have you checked? If not, do you have access to the serial interface?
 – Attie
 Dec 15 at 23:58
 
 
 
 
 
 
 
 
 
 @Attie I have no doubt that the HDMI output shows a login prompt. I'm trying to access it through ssh though and not plug a monitor into it. Per the readme from the site, you can enable ssh the way I outlined in the post. It's not working as described in their docs
 – vane
 Dec 16 at 0:12
 
 
 
 
 
 
 
 
 
 Well, as it's not working... your best option is to connect to it some other way... or mount the rootfs on another machine and investigate a dead filesystem...
 – Attie
 Dec 16 at 12:46
 
 
 
 
 
 
 
 
 
 
 
 ... you did make sure that the- sshfile has no extension, right?
 – Attie
 Dec 16 at 12:47
 
 
 
 
 
 
 
 
 
 looking at the source I'd suggest that it's not being triggered... two options: 1)- /bootisn't mounted in time / at all, 2) The service isn't enabled.
 – Attie
 Dec 16 at 12:50
 
 
 
 
 
|
show 1 more comment
I just downloaded and wrote the Raspbian Stretch headless image to a micro SD card. I added a DHCP configuration to give the ethernet adapter a 10.0.0.254 address. I then gave my desktop PC's ethernet adapter an address of 10.0.0.2 and connected the PC to the raspberry pi with an ethernet cable.
I tested that I am able to ping the raspberry pi on 10.0.0.254 so I know I'm able to communicate with it.
I then followed the instructions in item #3 of the remote access readme by placing a single empty file named ssh in the root of the boot partition. I mounted this partition on a linux system and verified it contains all the raspbian boot files (such as cmdline.txt).
When I put the SD card back into the pi and boot, the ssh file is not removed and I always get a connection refused message when attempting to ssh into the pi. Any clue what's going wrong? I used the headless image and this method of access to avoid using a separate monitor and keyboard so the fact that this isn't working is kind of a pain.
sshd raspbian
I just downloaded and wrote the Raspbian Stretch headless image to a micro SD card. I added a DHCP configuration to give the ethernet adapter a 10.0.0.254 address. I then gave my desktop PC's ethernet adapter an address of 10.0.0.2 and connected the PC to the raspberry pi with an ethernet cable.
I tested that I am able to ping the raspberry pi on 10.0.0.254 so I know I'm able to communicate with it.
I then followed the instructions in item #3 of the remote access readme by placing a single empty file named ssh in the root of the boot partition. I mounted this partition on a linux system and verified it contains all the raspbian boot files (such as cmdline.txt).
When I put the SD card back into the pi and boot, the ssh file is not removed and I always get a connection refused message when attempting to ssh into the pi. Any clue what's going wrong? I used the headless image and this method of access to avoid using a separate monitor and keyboard so the fact that this isn't working is kind of a pain.
sshd raspbian
sshd raspbian
asked Dec 15 at 23:35
vane
2271413
2271413
 
 
 
 
 
 
 I suspect the HDMI output will still show a login prompt... have you checked? If not, do you have access to the serial interface?
 – Attie
 Dec 15 at 23:58
 
 
 
 
 
 
 
 
 
 @Attie I have no doubt that the HDMI output shows a login prompt. I'm trying to access it through ssh though and not plug a monitor into it. Per the readme from the site, you can enable ssh the way I outlined in the post. It's not working as described in their docs
 – vane
 Dec 16 at 0:12
 
 
 
 
 
 
 
 
 
 Well, as it's not working... your best option is to connect to it some other way... or mount the rootfs on another machine and investigate a dead filesystem...
 – Attie
 Dec 16 at 12:46
 
 
 
 
 
 
 
 
 
 
 
 ... you did make sure that the- sshfile has no extension, right?
 – Attie
 Dec 16 at 12:47
 
 
 
 
 
 
 
 
 
 looking at the source I'd suggest that it's not being triggered... two options: 1)- /bootisn't mounted in time / at all, 2) The service isn't enabled.
 – Attie
 Dec 16 at 12:50
 
 
 
 
 
|
show 1 more comment
 
 
 
 
 
 
 I suspect the HDMI output will still show a login prompt... have you checked? If not, do you have access to the serial interface?
 – Attie
 Dec 15 at 23:58
 
 
 
 
 
 
 
 
 
 @Attie I have no doubt that the HDMI output shows a login prompt. I'm trying to access it through ssh though and not plug a monitor into it. Per the readme from the site, you can enable ssh the way I outlined in the post. It's not working as described in their docs
 – vane
 Dec 16 at 0:12
 
 
 
 
 
 
 
 
 
 Well, as it's not working... your best option is to connect to it some other way... or mount the rootfs on another machine and investigate a dead filesystem...
 – Attie
 Dec 16 at 12:46
 
 
 
 
 
 
 
 
 
 
 
 ... you did make sure that the- sshfile has no extension, right?
 – Attie
 Dec 16 at 12:47
 
 
 
 
 
 
 
 
 
 looking at the source I'd suggest that it's not being triggered... two options: 1)- /bootisn't mounted in time / at all, 2) The service isn't enabled.
 – Attie
 Dec 16 at 12:50
 
 
 
 
 
I suspect the HDMI output will still show a login prompt... have you checked? If not, do you have access to the serial interface?
– Attie
Dec 15 at 23:58
I suspect the HDMI output will still show a login prompt... have you checked? If not, do you have access to the serial interface?
– Attie
Dec 15 at 23:58
@Attie I have no doubt that the HDMI output shows a login prompt. I'm trying to access it through ssh though and not plug a monitor into it. Per the readme from the site, you can enable ssh the way I outlined in the post. It's not working as described in their docs
– vane
Dec 16 at 0:12
@Attie I have no doubt that the HDMI output shows a login prompt. I'm trying to access it through ssh though and not plug a monitor into it. Per the readme from the site, you can enable ssh the way I outlined in the post. It's not working as described in their docs
– vane
Dec 16 at 0:12
Well, as it's not working... your best option is to connect to it some other way... or mount the rootfs on another machine and investigate a dead filesystem...
– Attie
Dec 16 at 12:46
Well, as it's not working... your best option is to connect to it some other way... or mount the rootfs on another machine and investigate a dead filesystem...
– Attie
Dec 16 at 12:46
... you did make sure that the
ssh file has no extension, right?– Attie
Dec 16 at 12:47
... you did make sure that the
ssh file has no extension, right?– Attie
Dec 16 at 12:47
looking at the source I'd suggest that it's not being triggered... two options: 1)
/boot isn't mounted in time / at all, 2) The service isn't enabled.– Attie
Dec 16 at 12:50
looking at the source I'd suggest that it's not being triggered... two options: 1)
/boot isn't mounted in time / at all, 2) The service isn't enabled.– Attie
Dec 16 at 12:50
|
show 1 more comment
                                1 Answer
                                1
                        
active
oldest
votes
I was able to get this working by modifying the sshswitch.service file to look for the ssh file in / instead if /boot. Then I created the ssh file in the root of the rootfs partition. Below is the modified sshswitch.service which is located at /lib/systemd/system/sshswitch.service.
 [Unit]
 Description=Turn on SSH if /ssh is present
 ConditionPathExistsGlob=/ssh{,.txt}
 After=regenerate_ssh_host_keys.service
 [Service]
 Type=oneshot
 ExecStart=/bin/sh -c "update-rc.d ssh enable && invoke-rc.d ssh start && rm -f /ssh ; rm -f /ssh.txt"
 [Install]
 WantedBy=multi-user.target
This is what I did to work around my issues, this is not a "fix" for the issue but it might help someone else in the same situation.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
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',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1384923%2fraspbian-headless-ssh-sshswitch-service-file-not-working%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
                                1 Answer
                                1
                        
active
oldest
votes
                                1 Answer
                                1
                        
active
oldest
votes
active
oldest
votes
active
oldest
votes
I was able to get this working by modifying the sshswitch.service file to look for the ssh file in / instead if /boot. Then I created the ssh file in the root of the rootfs partition. Below is the modified sshswitch.service which is located at /lib/systemd/system/sshswitch.service.
 [Unit]
 Description=Turn on SSH if /ssh is present
 ConditionPathExistsGlob=/ssh{,.txt}
 After=regenerate_ssh_host_keys.service
 [Service]
 Type=oneshot
 ExecStart=/bin/sh -c "update-rc.d ssh enable && invoke-rc.d ssh start && rm -f /ssh ; rm -f /ssh.txt"
 [Install]
 WantedBy=multi-user.target
This is what I did to work around my issues, this is not a "fix" for the issue but it might help someone else in the same situation.
add a comment |
I was able to get this working by modifying the sshswitch.service file to look for the ssh file in / instead if /boot. Then I created the ssh file in the root of the rootfs partition. Below is the modified sshswitch.service which is located at /lib/systemd/system/sshswitch.service.
 [Unit]
 Description=Turn on SSH if /ssh is present
 ConditionPathExistsGlob=/ssh{,.txt}
 After=regenerate_ssh_host_keys.service
 [Service]
 Type=oneshot
 ExecStart=/bin/sh -c "update-rc.d ssh enable && invoke-rc.d ssh start && rm -f /ssh ; rm -f /ssh.txt"
 [Install]
 WantedBy=multi-user.target
This is what I did to work around my issues, this is not a "fix" for the issue but it might help someone else in the same situation.
add a comment |
I was able to get this working by modifying the sshswitch.service file to look for the ssh file in / instead if /boot. Then I created the ssh file in the root of the rootfs partition. Below is the modified sshswitch.service which is located at /lib/systemd/system/sshswitch.service.
 [Unit]
 Description=Turn on SSH if /ssh is present
 ConditionPathExistsGlob=/ssh{,.txt}
 After=regenerate_ssh_host_keys.service
 [Service]
 Type=oneshot
 ExecStart=/bin/sh -c "update-rc.d ssh enable && invoke-rc.d ssh start && rm -f /ssh ; rm -f /ssh.txt"
 [Install]
 WantedBy=multi-user.target
This is what I did to work around my issues, this is not a "fix" for the issue but it might help someone else in the same situation.
I was able to get this working by modifying the sshswitch.service file to look for the ssh file in / instead if /boot. Then I created the ssh file in the root of the rootfs partition. Below is the modified sshswitch.service which is located at /lib/systemd/system/sshswitch.service.
 [Unit]
 Description=Turn on SSH if /ssh is present
 ConditionPathExistsGlob=/ssh{,.txt}
 After=regenerate_ssh_host_keys.service
 [Service]
 Type=oneshot
 ExecStart=/bin/sh -c "update-rc.d ssh enable && invoke-rc.d ssh start && rm -f /ssh ; rm -f /ssh.txt"
 [Install]
 WantedBy=multi-user.target
This is what I did to work around my issues, this is not a "fix" for the issue but it might help someone else in the same situation.
answered Dec 16 at 23:53
vane
2271413
2271413
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1384923%2fraspbian-headless-ssh-sshswitch-service-file-not-working%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I suspect the HDMI output will still show a login prompt... have you checked? If not, do you have access to the serial interface?
– Attie
Dec 15 at 23:58
@Attie I have no doubt that the HDMI output shows a login prompt. I'm trying to access it through ssh though and not plug a monitor into it. Per the readme from the site, you can enable ssh the way I outlined in the post. It's not working as described in their docs
– vane
Dec 16 at 0:12
Well, as it's not working... your best option is to connect to it some other way... or mount the rootfs on another machine and investigate a dead filesystem...
– Attie
Dec 16 at 12:46
... you did make sure that the
sshfile has no extension, right?– Attie
Dec 16 at 12:47
looking at the source I'd suggest that it's not being triggered... two options: 1)
/bootisn't mounted in time / at all, 2) The service isn't enabled.– Attie
Dec 16 at 12:50