missing linker lssh ubuntu compile failed

⚓ Rust    📅 2025-05-04    👤 surdeus    👁️ 9      

surdeus

Warning

This post was published 109 days ago. The information described in this article may have changed.

hi,
I am running ubuntu

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 24.04.2 LTS
Release:        24.04
Codename:       noble

rust version

rustup check                                                                                                                                                                  11:22:13
stable-x86_64-unknown-linux-gnu - Up to date : 1.86.0 (05f9846f8 2025-03-31)
rustup - Up to date : 1.28.1

rustup

rustup show                                                                                                                                                                   11:23:35
Default host: x86_64-unknown-linux-gnu
rustup home:  /home/karthick/.rustup

installed toolchains
--------------------
stable-x86_64-unknown-linux-gnu (active, default)
1.76.0-x86_64-unknown-linux-gnu

active toolchain
----------------
name: stable-x86_64-unknown-linux-gnu
active because: it's the default toolchain
installed targets:
  x86_64-unknown-linux-gnu

version

rustup update                                                                                                                                                                 11:23:41
info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
info: checking for self-update

  stable-x86_64-unknown-linux-gnu unchanged - rustc 1.86.0 (05f9846f8 2025-03-31)

info: cleaning up downloads & tmp directories

I am trying to connect to ssh server locally.
my code is as below

fn main() {
    let mut session = ssh::Session::new().unwrap();
    let _ = session.set_host("localhost").unwrap();
    let _ = session.connect().unwrap();
}

running the command to run via cargo cargo run
error message

 cargo run                                                                                                                                               11:26:39
   Compiling local-ssh v0.1.0 (/home/karthick/code/local-ssh)
error: linking with `cc` failed: exit status: 1
  |
  = note:  "cc" "-m64" "/tmp/rustcd4erH4/symbols.o" "<8 object files omitted>" "-Wl,--as-needed" "-Wl,-Bstatic" "/home/karthick/code/local-ssh/target/debug/deps/{libssh-a199393cebd6b414.rlib,libbitflags-d7225e88044e50f3.rlib,liblog-f3ebedc5a0014601.rlib,liblog-ff97d2b12ce05993.rlib,liblibc-b1c52a7bcf14e644.rlib}.rlib" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib/{libstd-*,libpanic_unwind-*,libobject-*,libmemchr-*,libaddr2line-*,libgimli-*,librustc_demangle-*,libstd_detect-*,libhashbrown-*,librustc_std_workspace_alloc-*,libminiz_oxide-*,libadler2-*,libunwind-*,libcfg_if-*,liblibc-*,liballoc-*,librustc_std_workspace_core-*,libcore-*,libcompiler_builtins-*}.rlib" "-Wl,-Bdynamic" "-lssh" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/home/karthick/code/local-ssh/target/debug/deps/local_ssh-98a667c6ce83f7b7" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs"
  = note: some arguments are omitted. use `--verbose` to show all linker arguments
  = note: /usr/bin/ld: cannot find -lssh: No such file or directory
          collect2: error: ld returned 1 exit status


error: could not compile `local-ssh` (bin "local-ssh") due to 1 previous error

I understand from error message the linker is not able to find lssh.
tried the following

  • I did google around and installed
    openssh-server
    libssl-dev
  • tested connectivity using terminal locally ssh localhost and it works as expected
  • checked status of ssh in system using sudo systemctl status ssh and confirmed is active
    In my system lssh is not found and googled around can not find lssh reference around.
    Any help or pointers appreciated.

2 posts - 2 participants

Read full topic

🏷️ rust_feed