SFTP connection in RUST. How to add KexAlgorithms and HostKeyAlgorithms?

I am very new at RUST and am having difficulty with the SFTP connection.

I was trying to use openssh with openssh_sftp_client. This is the code I am working on (it is just from openssh document).

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>use openssh::{Session, Stdio, SessionBuilder};
use openssh_sftp_client::Sftp;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let builder = SessionBuilder::default();
let (builder, destination) = builder.resolve("ssh://username@hostname:22");
let tempdir = builder.launch_master(destination).await?;
let session = Session::new_process_mux(tempdir);
println!("Session created");
let mut child = session
.subsystem("sftp")
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.spawn()
.await?;
println!("Child spawned");
Sftp::new(
child.stdin().take().unwrap(),
child.stdout().take().unwrap(),
Default::default(),
)
.await?
.close()
.await?;
Ok(())
}
</code>
<code>use openssh::{Session, Stdio, SessionBuilder}; use openssh_sftp_client::Sftp; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let builder = SessionBuilder::default(); let (builder, destination) = builder.resolve("ssh://username@hostname:22"); let tempdir = builder.launch_master(destination).await?; let session = Session::new_process_mux(tempdir); println!("Session created"); let mut child = session .subsystem("sftp") .stdin(Stdio::piped()) .stdout(Stdio::piped()) .spawn() .await?; println!("Child spawned"); Sftp::new( child.stdin().take().unwrap(), child.stdout().take().unwrap(), Default::default(), ) .await? .close() .await?; Ok(()) } </code>
use openssh::{Session, Stdio, SessionBuilder};
use openssh_sftp_client::Sftp;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let builder = SessionBuilder::default();
    let (builder, destination) = builder.resolve("ssh://username@hostname:22");
    
    let tempdir = builder.launch_master(destination).await?;

    let session = Session::new_process_mux(tempdir);
    println!("Session created");

    let mut child = session
        .subsystem("sftp")
        .stdin(Stdio::piped())
        .stdout(Stdio::piped())
        .spawn()
        .await?;
    println!("Child spawned");

    Sftp::new(
        child.stdin().take().unwrap(),
        child.stdout().take().unwrap(),
        Default::default(),
    )
    .await?
    .close()
    .await?;

    Ok(())
}

However, I cannot make it work. let session = Session::new_process_mux(tempdir); part seems to be problematic. Below is the message I got when I ran the code.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>Error: Connect(Custom { kind: ConnectionAborted,
error: "Unable to negotiate with 198.55.199.53 port 22: no matching key exchange method found.
Their offer: diffie-hellman-group1-sha1,diffie-hellman-group14-sha1" })
</code>
<code>Error: Connect(Custom { kind: ConnectionAborted, error: "Unable to negotiate with 198.55.199.53 port 22: no matching key exchange method found. Their offer: diffie-hellman-group1-sha1,diffie-hellman-group14-sha1" }) </code>
Error: Connect(Custom { kind: ConnectionAborted, 
    error: "Unable to negotiate with 198.55.199.53 port 22: no matching key exchange method found. 
    Their offer: diffie-hellman-group1-sha1,diffie-hellman-group14-sha1" })

When I accessed through Mac terminal, I used below config, and ~ $ sftp DATA easily connects to the server.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>Host DATA
HostName hostname
User username
KexAlgorithms +diffie-hellman-group14-sha1
HostKeyAlgorithms=+ssh-dss
</code>
<code>Host DATA HostName hostname User username KexAlgorithms +diffie-hellman-group14-sha1 HostKeyAlgorithms=+ssh-dss </code>
Host DATA
  HostName hostname
  User username
  KexAlgorithms +diffie-hellman-group14-sha1
  HostKeyAlgorithms=+ssh-dss

I think KexAlgorithms and HostKeyAlgorithms parts are the problems I couldn’t incorporate into rust code. Is there any way to deal with this?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật