Community discussions

MikroTik App
 
OKNET
Member
Member
Topic Author
Posts: 354
Joined: Mon Jun 22, 2015 9:22 am

Passwordless SSH login FROM routerboard INTO debian [SOLVED]

Mon Oct 14, 2019 10:35 am

I need to login from routerboard (ssh client or ssh-exec) into a debian system without password.

I have generated a RSA key pair into Debian system and copied both into ./ssh/authorized_keys
I have copied those keys into routerboard and correctly imported

When I try to login into Debian it still asks for password (and , anyway, once correct password is given it says wrong password)

Where am I wrong ??

Should I perhaps do the opposite : generate RSA pair into routerboard and import into Debian ??
Last edited by OKNET on Fri Oct 18, 2019 11:20 am, edited 1 time in total.
 
User avatar
eworm
Forum Guru
Forum Guru
Posts: 1071
Joined: Wed Oct 22, 2014 9:23 am
Location: Oberhausen, Germany
Contact:

Re: Passwordless SSH login FROM routerboard INTO debian

Mon Oct 14, 2019 9:11 pm

You can not generate ssh key pair on RouterOS device. Please give some more specific information, for example output of "/user ssh-keys private print" and logs.
 
User avatar
32768
just joined
Posts: 23
Joined: Fri Mar 16, 2018 3:59 pm
Location: Switzerland
Contact:

Re: Passwordless SSH login FROM routerboard INTO debian

Tue Oct 15, 2019 12:12 am

As far as my knowledge goes you must use the public key, of the key used on the routerboard device, on the debian system and configure the debian sshd to authorize logins by keys.

// 32768
 
OKNET
Member
Member
Topic Author
Posts: 354
Joined: Mon Jun 22, 2015 9:22 am

Re: Passwordless SSH login FROM routerboard INTO debian

Fri Oct 18, 2019 10:15 am

I've understood that private RSA key of client must be copied into ~/.ssh/authorized_key of server
Just proven this works for a passwordless login from debian client to debian server.

Now, what RSA key of mikrotik should I use to be copied into server authorized_key ??

If I cannot issue a RSA key from routerboard, is this definitely not going to work ?

! RESET !

My fault :

the authorized_key file must be enabled (uncommented) in /etc/ssh/sshd_config on server :
AuthorizedKeysFile %h/.ssh/authorized_keys
So:


Server side:

Generate a key pair :
ssh-keygen -t RSA -m PEM -f mikrotik
(hit enter at passphrase prompt for the empty password)

Copy the .pub key into authorized_keys:
cat mikrotik.pub >> ~/.ssh/authorized_key

Copy both keys (via scp, ssh, whatever_you_want) to routerboard file folder.

Routerboard side:

Import the private key:
/user ssh-keys private import private-key-file=mikrotik public-key-file=mikrotik.pub user=admin
(hit enter at passphrase prompt for the empty password)

Done !

You can login to remote server via
/system ssh user=<user>  <host>
or 
/system ssh-exec address=<address> user=<user> command="putyourcommandhere"

Who is online

Users browsing this forum: adwlodaro, Bing [Bot], cvrnaught, McSee and 116 guests