@@ -1,12 +1,8 @@
11use std::{
2− env,
3− fs,
2+ env, fs,
43 io::{self, Write},
54 net::{SocketAddr, TcpStream},
6− os::unix::{
7− fs::PermissionsExt,
8− io::OwnedFd,
9− },
5+ os::unix::{fs::PermissionsExt, io::OwnedFd},
106 path::{Path, PathBuf},
117 process::{Command, Stdio},
128 sync::{
@@ -17,8 +13,8 @@ use std::{
1713};
1814
1915use serde::{Deserialize, Serialize};
20−use uuid::Uuid;
2116use std::sync::mpsc::Sender;
17+use uuid::Uuid;
2218
2319use crate::{
2420 session_manager::INSTANCE_DIR_NAME,
@@ -30,7 +26,7 @@ const INSTANCE_TOML: &str = "instance.toml";
3026const SSH_KEY_NAME: &str = "ssh_key";
3127const SERIAL_LOG_NAME: &str = "serial.log";
3228const SSH_GUEST_DIR: &str = "/root/.vibebox";
33−const DEFAULT_SSH_USER: &str = "vibebox";
29+const DEFAULT_SSH_USER: &str = "vibecoder";
3430const SSH_CONNECT_RETRIES: usize = 30;
3531const SSH_CONNECT_DELAY_MS: u64 = 500;
3632const SSH_SETUP_SCRIPT: &str = include_str!("ssh.sh");
@@ -76,12 +72,8 @@ pub fn run_with_ssh(
7672 true,
7773 )?];
7874
79− let extra_login_actions = build_ssh_login_actions(
80− &config,
81− &project_name,
82− SSH_GUEST_DIR,
83− SSH_KEY_NAME,
84− );
75+ let extra_login_actions =
76+ build_ssh_login_actions(&config, &project_name, SSH_GUEST_DIR, SSH_KEY_NAME);
8577
8678 vm::run_with_args_and_extras(
8779 args,
@@ -107,7 +99,9 @@ fn ensure_instance_dir(project_root: &Path) -> Result<PathBuf, io::Error> {
10799 Ok(instance_dir)
108100}
109101
110−fn ensure_ssh_keypair(instance_dir: &Path) -> Result<(PathBuf, PathBuf), Box<dyn std::error::Error>> {
102+fn ensure_ssh_keypair(
103+ instance_dir: &Path,
104+) -> Result<(PathBuf, PathBuf), Box<dyn std::error::Error>> {
111105 let private_key = instance_dir.join(SSH_KEY_NAME);
112106 let public_key = instance_dir.join(format!("{SSH_KEY_NAME}.pub"));
113107
@@ -129,12 +123,13 @@ fn ensure_ssh_keypair(instance_dir: &Path) -> Result<(PathBuf, PathBuf), Box<dyn
129123 "-N",
130124 "",
131125 "-f",
132− private_key
133− .to_str()
134− .ok_or("ssh key path not utf-8")?,
126+ private_key.to_str().ok_or("ssh key path not utf-8")?,
135127 "-C",
136128 "vibebox",
137129 ])
130+ .stdin(Stdio::null())
131+ .stdout(Stdio::null())
132+ .stderr(Stdio::inherit())
138133 .status()?;
139134
140135 if !status.success() {
@@ -283,8 +278,7 @@ fn spawn_ssh_io(
283278 let ssh_connected = Arc::new(AtomicBool::new(false));
284279 let ssh_started = Arc::new(AtomicBool::new(false));
285280 let ssh_ready = Arc::new(AtomicBool::new(false));
286− let input_tx_holder: Arc<Mutex<Option<Sender<VmInput>>>> =
287− Arc::new(Mutex::new(None));
281+ let input_tx_holder: Arc<Mutex<Option<Sender<VmInput>>>> = Arc::new(Mutex::new(None));
288282
289283 let instance_path = instance_dir.join(INSTANCE_TOML);
290284 let config_for_output = config.clone();
@@ -415,9 +409,7 @@ fn spawn_ssh_io(
415409 );
416410 break;
417411 }
418− thread::sleep(std::time::Duration::from_millis(
419− SSH_CONNECT_DELAY_MS,
420− ));
412+ thread::sleep(std::time::Duration::from_millis(SSH_CONNECT_DELAY_MS));
421413 continue;
422414 }
423415
@@ -427,9 +419,7 @@ fn spawn_ssh_io(
427419 let status = Command::new("ssh")
428420 .args([
429421 "-i",
430− ssh_key_for_thread
431− .to_str()
432− .unwrap_or(".vibebox/ssh_key"),
422+ ssh_key_for_thread.to_str().unwrap_or(".vibebox/ssh_key"),
433423 "-o",
434424 "IdentitiesOnly=yes",
435425 "-o",
@@ -447,6 +437,9 @@ fn spawn_ssh_io(
447437 "-o",
448438 "ConnectTimeout=5",
449439 ])
440+ .env_remove("LC_CTYPE")
441+ .env_remove("LC_ALL")
442+ // .env_remove("LANG")
450443 .arg(format!("{ssh_user}@{ip}"))
451444 .stdin(Stdio::inherit())
452445 .stdout(Stdio::inherit())
@@ -458,8 +451,7 @@ fn spawn_ssh_io(
458451 ssh_connected_for_thread.store(false, Ordering::SeqCst);
459452 eprintln!("[vibebox] ssh exited with status: {status}");
460453 if let Some(tx) = input_tx_holder_for_thread.lock().unwrap().clone() {
461− let _ =
462− tx.send(VmInput::Bytes(b"systemctl poweroff\n".to_vec()));
454+ let _ = tx.send(VmInput::Bytes(b"systemctl poweroff\n".to_vec()));
463455 }
464456 break;
465457 }
@@ -479,8 +471,7 @@ fn spawn_ssh_io(
479471 ssh_connected_for_thread.store(false, Ordering::SeqCst);
480472 eprintln!("[vibebox] ssh exited with status: {status}");
481473 if let Some(tx) = input_tx_holder_for_thread.lock().unwrap().clone() {
482− let _ =
483− tx.send(VmInput::Bytes(b"systemctl poweroff\n".to_vec()));
474+ let _ = tx.send(VmInput::Bytes(b"systemctl poweroff\n".to_vec()));
484475 }
485476 break;
486477 }