[Solved] Cant get no ssh connection with switch in linux

This thread has been locked for further replies. You can start a new thread to share your ideas or ask questions.

[Solved] Cant get no ssh connection with switch in linux

This thread has been locked for further replies. You can start a new thread to share your ideas or ask questions.
[Solved] Cant get no ssh connection with switch in linux
[Solved] Cant get no ssh connection with switch in linux
2023-05-20 01:38:39 - last edited 2023-06-28 10:44:41
Hardware Version: V2
Firmware Version: 2.0.6 Build 20200805 Rel.57865

Hello everyone,

 

In Home Assistant i want to make a ssh connection with the switch (I have the docker version of Home Assistant with version 2023.5.3). This is because i want to make a python script to enable or disable PoE on a specific port. Alas I cannot get a connection. i tried to generate a rsa public and private key with 2048 bits with ssh-keygen. The SSH-server on the switch is enabled. I downloaded the public key in the switch. I tried to copy the public key to ~/.ssh/authorized_keys with ssh-copy-id. Both the public key and ~/.ssh/authorized_keys have file permissions of 600. But when using ssh-copy-id i get an error: Unable to negotiate with switch_ip port 22: no matching key exchange method found. Their offer: diffie-hellman-group1-sha1. In ~/.ssh/config i added some algorithms:

 

Host jetstream
    hostname ip_address
    KexAlgorithms diffie-hellman-group1-sha1
    HostKeyAlgorithms +ssh-dss
    Ciphers aes128-ctr,aes192-ctr,aes256-ctr,aes128-cbc,aes192-cbc,aes256-cbc,3des-cbc,
    user admin
    PreferredAuthentications publickey
    IdentityFile id_rsa

Host *
    KexAlgorithms curve25519-sha256...

 

I get ping replies from the switch in Home Assistant. When I put the line PreferredAuthentications publickey, password in ~/.ssh/config I can connect to the switch. It is asking for a password, but that is not what I want. What am I missing? Will someone please help me?
 

  0      
  0      
#1
Options
1 Accepted Solution
Re:Cant get no ssh connection with switch in linux-Solution
2023-06-28 10:38:29 - last edited 2023-06-28 10:44:41

  @Tedd404 Thank you for your reply and thinking with me.

 

I found out What the issue here is. Linux uses OpenSSH, which has a different format than Putty. You have to convert the putty private key in the following way:

 

Do the following in linux:

 

- Install putty tools

- Generate private/public key pair with:

     puttygen -t rsa -b 2048 -o pp_id_rsa.ppk

- Convert to OpenSSH format:

     puttygen pp_id_rsa.ppk -O public-openssh -o id_rsa.pub

- Extract public key:

     puttygen pp_id_rsa.ppk -O public -o pp_id_rsa.pub

- Extract private key:

     puttygen pp_id_rsa.ppk -O private-openssh -o id_rsa

Import pp_id_rsa.pub to SSH server

Copy id_rsa to ~/.ssh and chmod 600 ~/.ssh/id_rsa

 

Now I can access the switch with SSH without password.

Recommended Solution
  0  
  0  
#3
Options
3 Reply
Re:Cant get no ssh connection with switch in linux
2023-06-28 09:17:39

  @Gaijin66 

suggest you check with your windows and see if ssh is working. does not seem to be a problem with the switch so far. 

nothing to do with the docker/HA. you should check if ssh is available on the switch. no need to tweak your certificate and stuff.

ScReW yOu gUyS. I aM GOinG hoMe. —————————————————————— For heaven's sake, can you write and describe your issue based on plain fact, common logic and a methodologic approach? Appreciate it.
  0  
  0  
#2
Options
Re:Cant get no ssh connection with switch in linux-Solution
2023-06-28 10:38:29 - last edited 2023-06-28 10:44:41

  @Tedd404 Thank you for your reply and thinking with me.

 

I found out What the issue here is. Linux uses OpenSSH, which has a different format than Putty. You have to convert the putty private key in the following way:

 

Do the following in linux:

 

- Install putty tools

- Generate private/public key pair with:

     puttygen -t rsa -b 2048 -o pp_id_rsa.ppk

- Convert to OpenSSH format:

     puttygen pp_id_rsa.ppk -O public-openssh -o id_rsa.pub

- Extract public key:

     puttygen pp_id_rsa.ppk -O public -o pp_id_rsa.pub

- Extract private key:

     puttygen pp_id_rsa.ppk -O private-openssh -o id_rsa

Import pp_id_rsa.pub to SSH server

Copy id_rsa to ~/.ssh and chmod 600 ~/.ssh/id_rsa

 

Now I can access the switch with SSH without password.

Recommended Solution
  0  
  0  
#3
Options
Re:Cant get no ssh connection with switch in linux
2023-09-12 10:42:42

@Gaijin66 Why not utilize the ssh-keygen utility? It's part of OpenSSH, which is the de facto standard SSH library adopted by all Linux distributions.

 

ssh-keygen -t rsa -N '' -C "yourname@domain.tld" -f .ssh/id_rsa_yourname

 

This will generate an RSA private key pair with a default key length of 3072 bits, depending on the version of OpenSSH installed on your system.

 

The following files will be created:

 

.ssh/id_rsa_yourname
.ssh/id_rsa_yourname.pub

No need for PuTTY ...

Building Better Networks, Together.
  0  
  0  
#4
Options