0

I'd like to connect to a LXC container through Proxmox via SSH without having SSH access to the container itself, so I can get the desired outcome by connecting to the Proxmox host first and then running lxc-attach <ID> to connect to my container.

Now I'd like to do this in one go. For this I have a function in my rc file:

sshc() { ssh $1 "lxc-attach $2; bash -i" }

It works, but in the terminal it looks like this:

I don't see the user and current directory name in the prompt

This should look different, i.e.:

root@root1543:~# lxc-attach 1111
root@container:~# pwd
/root
root@container:~#

I want to see the user and host in the current shell, which I do not see in my solution.

I also considered to alter RemoteCommand in the SSH config, but apparently, it's impossible to have an argument passed into RemoteCommand, so I ditched that attempt.

1 Answer 1

1

Add the "-t" option to your ssh invocation:

sshc() { ssh -t $1 "lxc-attach $2; bash -i" }

When ssh is invoked with a command to run on the remote system, it doesn't allocate a TTY for the session by default. Adding "-t" tells ssh to requesta TTY for the session.

Interactive sessions normally operate through a TTY to provide certain features like the ability to use the backspace key to edit what you've typed. Your shell also uses the presence of a TTY to determine whether to operate interactively, e.g. by printing command-line prompts.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .