Fix ssh/scp/sftp for containers running as a uid without passwd entry
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d58b23d35f
commit
fccaee4b94
5 files changed
+33
-2
No files matched your search
@@ -126,7 +126,10 @@ pub fn write_files(app: &App, user: &User, s: &SshSettings) -> Result<()> {
|
||||
chmod(&host_cfg, 0o600)?;
|
||||
for (bin, config) in [(bin_dir(&home), format!("'{}'", host_cfg.display())), (home.join(SANDBOX_BIN), "\"$HOME/.ssh/config-sandbox\"".to_string())] {
|
||||
std::fs::create_dir_all(&bin)?;
|
||||
for (name, real) in [("ssh", "/usr/bin/ssh"), ("scp", "/usr/bin/scp"), ("sftp", "/usr/bin/sftp")] {
|
||||
for name in ["ssh", "scp", "sftp"] {
|
||||
// The image's /usr/local/bin wrappers cope with a uid without passwd entry.
|
||||
let local = format!("/usr/local/bin/{name}");
|
||||
let real = if Path::new(&local).exists() { local } else { format!("/usr/bin/{name}") };
|
||||
let p = bin.join(name);
|
||||
std::fs::write(&p, format!("#!/bin/sh\nexec {real} -F {config} \"$@\"\n"))?;
|
||||
chmod(&p, 0o755)?;
|
||||
|
||||
Reference in new issue
Block a user