How to run a command automatically everytime I log into a remote server via ssh without disconnecting the session
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I am trying to have my ssh set up using this answer
I am using the command:
sshpass -p myrealpassword ssh byteme@byteme.com.au -t 'cd web && git status'
It is working OK and I am able to run a command everytime I log in but I get an error message:
Connection to byteme.com.au closed.
right after running the remote command.
How can I run this command without getting kicked out of my ssh session?
linux centos
New contributor
add a comment |Â
up vote
0
down vote
favorite
I am trying to have my ssh set up using this answer
I am using the command:
sshpass -p myrealpassword ssh byteme@byteme.com.au -t 'cd web && git status'
It is working OK and I am able to run a command everytime I log in but I get an error message:
Connection to byteme.com.au closed.
right after running the remote command.
How can I run this command without getting kicked out of my ssh session?
linux centos
New contributor
maybe to use daemon?
â Dillinger è morto
16 mins ago
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am trying to have my ssh set up using this answer
I am using the command:
sshpass -p myrealpassword ssh byteme@byteme.com.au -t 'cd web && git status'
It is working OK and I am able to run a command everytime I log in but I get an error message:
Connection to byteme.com.au closed.
right after running the remote command.
How can I run this command without getting kicked out of my ssh session?
linux centos
New contributor
I am trying to have my ssh set up using this answer
I am using the command:
sshpass -p myrealpassword ssh byteme@byteme.com.au -t 'cd web && git status'
It is working OK and I am able to run a command everytime I log in but I get an error message:
Connection to byteme.com.au closed.
right after running the remote command.
How can I run this command without getting kicked out of my ssh session?
linux centos
linux centos
New contributor
New contributor
New contributor
asked 18 mins ago
byte me
1
1
New contributor
New contributor
maybe to use daemon?
â Dillinger è morto
16 mins ago
add a comment |Â
maybe to use daemon?
â Dillinger è morto
16 mins ago
maybe to use daemon?
â Dillinger è morto
16 mins ago
maybe to use daemon?
â Dillinger è morto
16 mins ago
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
0
down vote
When you pass a command to SSH the way you're doing, it does not run a shell, it runs only the command you passed. You can try to attach to a "new" shell by adding a && bash -i
to the end of your command, though that will give you a shell with some unexpected behaviors, or you can simply add those commands to your .bashrc
or .bash_profile
files to be executed at login, and not run them as part of the SSH command.
sshpass -p myrealpassword ssh byteme@byteme.com.au -t 'cd web && git status && bash -i'
worked. Thanks. Is there a way I can compare the two shells?
â byte me
6 mins ago
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
When you pass a command to SSH the way you're doing, it does not run a shell, it runs only the command you passed. You can try to attach to a "new" shell by adding a && bash -i
to the end of your command, though that will give you a shell with some unexpected behaviors, or you can simply add those commands to your .bashrc
or .bash_profile
files to be executed at login, and not run them as part of the SSH command.
sshpass -p myrealpassword ssh byteme@byteme.com.au -t 'cd web && git status && bash -i'
worked. Thanks. Is there a way I can compare the two shells?
â byte me
6 mins ago
add a comment |Â
up vote
0
down vote
When you pass a command to SSH the way you're doing, it does not run a shell, it runs only the command you passed. You can try to attach to a "new" shell by adding a && bash -i
to the end of your command, though that will give you a shell with some unexpected behaviors, or you can simply add those commands to your .bashrc
or .bash_profile
files to be executed at login, and not run them as part of the SSH command.
sshpass -p myrealpassword ssh byteme@byteme.com.au -t 'cd web && git status && bash -i'
worked. Thanks. Is there a way I can compare the two shells?
â byte me
6 mins ago
add a comment |Â
up vote
0
down vote
up vote
0
down vote
When you pass a command to SSH the way you're doing, it does not run a shell, it runs only the command you passed. You can try to attach to a "new" shell by adding a && bash -i
to the end of your command, though that will give you a shell with some unexpected behaviors, or you can simply add those commands to your .bashrc
or .bash_profile
files to be executed at login, and not run them as part of the SSH command.
When you pass a command to SSH the way you're doing, it does not run a shell, it runs only the command you passed. You can try to attach to a "new" shell by adding a && bash -i
to the end of your command, though that will give you a shell with some unexpected behaviors, or you can simply add those commands to your .bashrc
or .bash_profile
files to be executed at login, and not run them as part of the SSH command.
answered 12 mins ago
John
11.3k11730
11.3k11730
sshpass -p myrealpassword ssh byteme@byteme.com.au -t 'cd web && git status && bash -i'
worked. Thanks. Is there a way I can compare the two shells?
â byte me
6 mins ago
add a comment |Â
sshpass -p myrealpassword ssh byteme@byteme.com.au -t 'cd web && git status && bash -i'
worked. Thanks. Is there a way I can compare the two shells?
â byte me
6 mins ago
sshpass -p myrealpassword ssh byteme@byteme.com.au -t 'cd web && git status && bash -i'
worked. Thanks. Is there a way I can compare the two shells?â byte me
6 mins ago
sshpass -p myrealpassword ssh byteme@byteme.com.au -t 'cd web && git status && bash -i'
worked. Thanks. Is there a way I can compare the two shells?â byte me
6 mins ago
add a comment |Â
byte me is a new contributor. Be nice, and check out our Code of Conduct.
byte me is a new contributor. Be nice, and check out our Code of Conduct.
byte me is a new contributor. Be nice, and check out our Code of Conduct.
byte me is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f480478%2fhow-to-run-a-command-automatically-everytime-i-log-into-a-remote-server-via-ssh%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
maybe to use daemon?
â Dillinger è morto
16 mins ago