autossh works as expected by systemd setup for boot failsSSH accepts publickey authetication but won't...

Why the color red for the Republican Party

Accepted offer letter, position changed

Virginia employer terminated employee and wants signing bonus returned

Books that are narrated using various points of view of the main characters

Can Mathematica be used to create an Artistic 3D extrusion from a 2D image and wrap a line pattern around it?

Can you reject a postdoc offer after the PI has paid a large sum for flights/accommodation for your visit?

What was the Kree's motivation in Captain Marvel?

How is the wildcard * interpreted as a command?

How can The Temple of Elementary Evil reliably protect itself against kinetic bombardment?

Reversed Sudoku

In the late 1940’s to early 1950’s what technology was available that could melt a LOT of ice?

What problems would a superhuman have whose skin is constantly hot?

Database Backup for data and log files

Why does Captain Marvel assume the people on this planet know this?

Reverse string, can I make it faster?

Why would one plane in this picture not have gear down yet?

Should I tell my boss the work he did was worthless

What wound would be of little consequence to a biped but terrible for a quadruped?

weren't playing vs didn't play

How to secure an aircraft at a transient parking space?

Good for you! in Russian

Could you please stop shuffling the deck and play already?

At what distance can a bugbear, holding a reach weapon, with the Polearm Master feat, get their Opportunity Attack?

If I receive an SOS signal, what is the proper response?



autossh works as expected by systemd setup for boot fails


SSH accepts publickey authetication but won't connect with an identify file?Loggin in ssh server: Permission denied, please try againOpenSSH disable ControlMaster for given hostnamereliable systemd service for autosshFailed to find Linux Kernel ModuleI can no longer SSH to a VM on GCP after breaking ssh configurationcorosync systemd resource does not reflect service statusssl connection to aws serverless auroraDisabling systemd messages that interfere with running BASH scriptSSH - Retrieve public key from incoming connections













0















So I setup my ssh variables to do a reverse tunnel in ~/.ssh/config and called the host tunnel_reverse. I tested the following command to create a persisting tunnel with autossh and it worked just as expected:



    autossh -M 0 -N tunnel_reverse


I was able to connect to the remote computer from a laptop after the remote host reverse tunnel was created. However, when I tried to setup a service file so it could autostart at bootup with systemd, it wouldn't work. Here's the /etc/systemd/system/tunnel.service file I created:



    [Unit]
Description=AutoSSH to reverse tunnel
After=network.target

[Service]
Environment="AUTOSSH_GATETIME=0"
ExecStart=/usr/bin/autossh -M 0 -v -N tunnel_reverse

[Install]
WantedBy=multi-user.target


so I started that with



    systemctl daemon-reload
systemctl restart tunnel.service
systemctl status tunnel.service


Viewing the status log, it seems there is an error that reads:



    debug1: Server host key: blah blah blah
debug1: read_passpphrase: can't open /dev/tty: No such device or address
Host key verification failed.
ssh exited with error status 255; restarting ssh


Where did I go wrong?










share|improve this question
















bumped to the homepage by Community 14 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.











  • 1





    which distro is this being run on?

    – Mike
    Sep 9 '17 at 4:26











  • Ubuntu 16.04.3 LTS

    – Geryon
    Sep 9 '17 at 4:43
















0















So I setup my ssh variables to do a reverse tunnel in ~/.ssh/config and called the host tunnel_reverse. I tested the following command to create a persisting tunnel with autossh and it worked just as expected:



    autossh -M 0 -N tunnel_reverse


I was able to connect to the remote computer from a laptop after the remote host reverse tunnel was created. However, when I tried to setup a service file so it could autostart at bootup with systemd, it wouldn't work. Here's the /etc/systemd/system/tunnel.service file I created:



    [Unit]
Description=AutoSSH to reverse tunnel
After=network.target

[Service]
Environment="AUTOSSH_GATETIME=0"
ExecStart=/usr/bin/autossh -M 0 -v -N tunnel_reverse

[Install]
WantedBy=multi-user.target


so I started that with



    systemctl daemon-reload
systemctl restart tunnel.service
systemctl status tunnel.service


Viewing the status log, it seems there is an error that reads:



    debug1: Server host key: blah blah blah
debug1: read_passpphrase: can't open /dev/tty: No such device or address
Host key verification failed.
ssh exited with error status 255; restarting ssh


Where did I go wrong?










share|improve this question
















bumped to the homepage by Community 14 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.











  • 1





    which distro is this being run on?

    – Mike
    Sep 9 '17 at 4:26











  • Ubuntu 16.04.3 LTS

    – Geryon
    Sep 9 '17 at 4:43














0












0








0








So I setup my ssh variables to do a reverse tunnel in ~/.ssh/config and called the host tunnel_reverse. I tested the following command to create a persisting tunnel with autossh and it worked just as expected:



    autossh -M 0 -N tunnel_reverse


I was able to connect to the remote computer from a laptop after the remote host reverse tunnel was created. However, when I tried to setup a service file so it could autostart at bootup with systemd, it wouldn't work. Here's the /etc/systemd/system/tunnel.service file I created:



    [Unit]
Description=AutoSSH to reverse tunnel
After=network.target

[Service]
Environment="AUTOSSH_GATETIME=0"
ExecStart=/usr/bin/autossh -M 0 -v -N tunnel_reverse

[Install]
WantedBy=multi-user.target


so I started that with



    systemctl daemon-reload
systemctl restart tunnel.service
systemctl status tunnel.service


Viewing the status log, it seems there is an error that reads:



    debug1: Server host key: blah blah blah
debug1: read_passpphrase: can't open /dev/tty: No such device or address
Host key verification failed.
ssh exited with error status 255; restarting ssh


Where did I go wrong?










share|improve this question
















So I setup my ssh variables to do a reverse tunnel in ~/.ssh/config and called the host tunnel_reverse. I tested the following command to create a persisting tunnel with autossh and it worked just as expected:



    autossh -M 0 -N tunnel_reverse


I was able to connect to the remote computer from a laptop after the remote host reverse tunnel was created. However, when I tried to setup a service file so it could autostart at bootup with systemd, it wouldn't work. Here's the /etc/systemd/system/tunnel.service file I created:



    [Unit]
Description=AutoSSH to reverse tunnel
After=network.target

[Service]
Environment="AUTOSSH_GATETIME=0"
ExecStart=/usr/bin/autossh -M 0 -v -N tunnel_reverse

[Install]
WantedBy=multi-user.target


so I started that with



    systemctl daemon-reload
systemctl restart tunnel.service
systemctl status tunnel.service


Viewing the status log, it seems there is an error that reads:



    debug1: Server host key: blah blah blah
debug1: read_passpphrase: can't open /dev/tty: No such device or address
Host key verification failed.
ssh exited with error status 255; restarting ssh


Where did I go wrong?







ubuntu ssh systemd ssh-tunnel






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 9 '17 at 21:49







Geryon

















asked Sep 9 '17 at 1:22









GeryonGeryon

11




11





bumped to the homepage by Community 14 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 14 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.










  • 1





    which distro is this being run on?

    – Mike
    Sep 9 '17 at 4:26











  • Ubuntu 16.04.3 LTS

    – Geryon
    Sep 9 '17 at 4:43














  • 1





    which distro is this being run on?

    – Mike
    Sep 9 '17 at 4:26











  • Ubuntu 16.04.3 LTS

    – Geryon
    Sep 9 '17 at 4:43








1




1





which distro is this being run on?

– Mike
Sep 9 '17 at 4:26





which distro is this being run on?

– Mike
Sep 9 '17 at 4:26













Ubuntu 16.04.3 LTS

– Geryon
Sep 9 '17 at 4:43





Ubuntu 16.04.3 LTS

– Geryon
Sep 9 '17 at 4:43










1 Answer
1






active

oldest

votes


















0














It looks like the ssh session started by systemd is looking for a password. I am assuming that when you are running autossh manually it uses public key authentication, and that the public key is stored in the home directory of the user who's executing this (your reference to ~/.ssh does not say which user's home directory it is). The autossh executed by systemd should be running as the same user and have access to the same .ssh directory, otherwise it will not be able to use the same username/password combination.



You can specify username the the service should run by adding User= directive to the Service section of tunnel.service file.






share|improve this answer
























  • That was exactly what the problem was! Thank you for a concise explanation of the error.

    – Geryon
    Sep 10 '17 at 18:26











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "2"
};
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
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f872776%2fautossh-works-as-expected-by-systemd-setup-for-boot-fails%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









0














It looks like the ssh session started by systemd is looking for a password. I am assuming that when you are running autossh manually it uses public key authentication, and that the public key is stored in the home directory of the user who's executing this (your reference to ~/.ssh does not say which user's home directory it is). The autossh executed by systemd should be running as the same user and have access to the same .ssh directory, otherwise it will not be able to use the same username/password combination.



You can specify username the the service should run by adding User= directive to the Service section of tunnel.service file.






share|improve this answer
























  • That was exactly what the problem was! Thank you for a concise explanation of the error.

    – Geryon
    Sep 10 '17 at 18:26
















0














It looks like the ssh session started by systemd is looking for a password. I am assuming that when you are running autossh manually it uses public key authentication, and that the public key is stored in the home directory of the user who's executing this (your reference to ~/.ssh does not say which user's home directory it is). The autossh executed by systemd should be running as the same user and have access to the same .ssh directory, otherwise it will not be able to use the same username/password combination.



You can specify username the the service should run by adding User= directive to the Service section of tunnel.service file.






share|improve this answer
























  • That was exactly what the problem was! Thank you for a concise explanation of the error.

    – Geryon
    Sep 10 '17 at 18:26














0












0








0







It looks like the ssh session started by systemd is looking for a password. I am assuming that when you are running autossh manually it uses public key authentication, and that the public key is stored in the home directory of the user who's executing this (your reference to ~/.ssh does not say which user's home directory it is). The autossh executed by systemd should be running as the same user and have access to the same .ssh directory, otherwise it will not be able to use the same username/password combination.



You can specify username the the service should run by adding User= directive to the Service section of tunnel.service file.






share|improve this answer













It looks like the ssh session started by systemd is looking for a password. I am assuming that when you are running autossh manually it uses public key authentication, and that the public key is stored in the home directory of the user who's executing this (your reference to ~/.ssh does not say which user's home directory it is). The autossh executed by systemd should be running as the same user and have access to the same .ssh directory, otherwise it will not be able to use the same username/password combination.



You can specify username the the service should run by adding User= directive to the Service section of tunnel.service file.







share|improve this answer












share|improve this answer



share|improve this answer










answered Sep 10 '17 at 0:08









EktichEktich

413




413













  • That was exactly what the problem was! Thank you for a concise explanation of the error.

    – Geryon
    Sep 10 '17 at 18:26



















  • That was exactly what the problem was! Thank you for a concise explanation of the error.

    – Geryon
    Sep 10 '17 at 18:26

















That was exactly what the problem was! Thank you for a concise explanation of the error.

– Geryon
Sep 10 '17 at 18:26





That was exactly what the problem was! Thank you for a concise explanation of the error.

– Geryon
Sep 10 '17 at 18:26


















draft saved

draft discarded




















































Thanks for contributing an answer to Server Fault!


  • 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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f872776%2fautossh-works-as-expected-by-systemd-setup-for-boot-fails%23new-answer', 'question_page');
}
);

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







Popular posts from this blog

Фонтен-ла-Гаярд Зміст Демографія | Економіка | Посилання |...

Список ссавців Італії Природоохоронні статуси | Список |...

Маріан Котлеба Зміст Життєпис | Політичні погляди |...