Skip to content

Instantly share code, notes, and snippets.

@hiroyuki-sato
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hiroyuki-sato/6cfac97d21a26e3d5cc9 to your computer and use it in GitHub Desktop.
Save hiroyuki-sato/6cfac97d21a26e3d5cc9 to your computer and use it in GitHub Desktop.
VyOS Bug#345 SSH command returns "Segmentation fault

Bug#345 SSH command returns "Segmentation fault"

There are two openssl packages in VyOS repositories.

Workaround

Users environment.

User CPU OS Hypervisor
@lina_taso AMD FX 8350 OS Windows 8.1 Update VM VMware Player 6.0.3
@twovs AMD Athlon(tm) 64 X2+ Solaris 11.1 X86 VirtualBox-4.3.14-95030-SunOS
hide AMD A8-5500 APU CentOS release 6.5 qemu-kvm-0.12.1.2-2.415.el6_5.14.x86_64
@sean_mcrobbie AMD E-450 VyOS (native) N/A
@jedipunkz AMD Turion II NEO N54L VyOS (native) N/A

Environment

vyos login: vyos
password: ***

Install image

vyos@vyos:~$ install system

Install

Would you like to continue: (Yes/No) [Yes]: Yes

Partition (Auto/Union/Parted/Skip) [Auto]: Auto

Install the image on? [sda]: sda

This will destroy all data on /dev/sda
Continue? (Yes/No): [No]: Yes

/dev/sda1 has old configuration directory!
Would you like me to save the data on it
before I delete it? (Yes/No) [Yes]: No

/dev/sda1 has SSH host keys
Would you like me to keep SSH keys on new install (Yes/No) [Yes]: No

I found the following configuration files
/opt/vyatta/etc/config/config.boot
Which one should I copy to sda? [/opt/vyatta/etc/config/config.boot]: <RETURN>

Enter password for administrator account
Enter password for user 'vyos': ****
Retype password for user 'vyos': ****

Which drive should GRUB modify the boot partition on? [sda] <RETURN>

After that

sudo strace ssh-keygen -q -N '' -t rsa -f /tmp/aaa

This will generate corrupt file.

reproduce procedure.

  • VyOS 1.1.0 64bit

ssh-keygen -q -N '' -t rsa -f /tmp/aaa

vyos@vyos1-1-0:~$ sudo strace ssh-keygen -q -N '' -t rsa -f /tmp/aaa
execve("/usr/bin/ssh-keygen", ["ssh-keygen", "-q", "-N", "", "-t", "rsa", "-f", "/tmp/aaa"], [/* 18 vars */]) = 0
brk(0)                                  = 0x7f9965a36000

Currupt file name should be stat("/tmp/aaa")

stat("-", 0x7fff76f47d40)               = -1 ENOENT (No such file or directory)
open("-", O_WRONLY|O_CREAT|O_TRUNC, 0600) = 3
...

write(3, "-----BEGIN RSA PRIVATE KEY-----\n"..., 1675) = 1675
close(3)                                = 0
munmap(0x7f9963929000, 4096)            = 0
open("\376.pub", O_WRONLY|O_CREAT|O_TRUNC, 0644) = 3


                    = ?
vyos@vyos1-1-0:~$ ls -l /tmp/
total 40
-rw-r--r-- 1 root root  388 Oct 30 11:16 ?.pub
-rw------- 1 root root 1679 Oct 30 11:09 ?
-rw-r--r-- 1 root root  388 Oct 30 11:09 #.pub
-rw------- 1 root root 1679 Oct 30 11:16 )
-rw-r--r-- 1 root root  388 Oct 30 11:09 Q.pub
-rw------- 1 root root 1679 Oct 30 11:17 U
-rw-r--r-- 1 root root  388 Oct 30 11:17 `.pub
-rw-r--r-- 1 root root  388 Oct 30 11:17 c.pub
-rw------- 1 root root 1679 Oct 30 11:09 d
-rw------- 1 root root 1679 Oct 30 11:17 ?
vyos@vyos1-1-0:~$ ldd `which ssh-keygen`
        linux-vdso.so.1 =>  (0x00007ffffabfe000)
        libcrypto.so.0.9.8 => /usr/lib/libcrypto.so.0.9.8 (0x00007f05a65c4000)
        libdl.so.2 => /lib/libdl.so.2 (0x00007f05a63c0000)
        libresolv.so.2 => /lib/libresolv.so.2 (0x00007f05a61a9000)
        libc.so.6 => /lib/libc.so.6 (0x00007f05a5e47000)
        libz.so.1 => /usr/lib/libz.so.1 (0x00007f05a5c30000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f05a6b83000)
vyos@vyos1-1-0:~$ openssl md5 /usr/lib/libcrypto.so.0.9.8
MD5(/usr/lib/libcrypto.so.0.9.8)= 056cf5648a34eecd09b7935146a5d68f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment