How can I input password in advance with SSH? [closed] - linux

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I often operat my remote vps.I write some script to simply my work.But every time after the line of ssh command,I have to input the password manually.How can I provide the password in the script and so that it will work on automatically,though I know it is not safe but my aim is just for convience.
I have tried many ways.
To be detailed,if I have a vps with the configuration as flows:
Protocol=SSH
Host=122.122.122.122
Port=22
UserName:root
Password:mypassword
I will write a script as flowers to connect the vps:
#!/bin/sh
ssh -p 22 root#122.122.122.122
#Other command flowers
Then I run the script.Before other command runs,I have to type the password.
root#122.122.122.122's password:
So I wonder if I have any solution to avoid typing password manually.

method 1:
first Create a new keypair:
ssh-keygen
Copy the public key to the server:
ssh-copy-id user#my.server.com
now server should recognize your key hence wont ask you for the password anymore:
ssh user#my.server.com
method 2:
use expect
#!/usr/bin/expect -f
spawn ssh user#my.server.com
expect "assword:"
send "mypassword\r"
interact

Related

Permission to access another remote server Linux, Ubuntu [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
How can I allow a remote server to run a command without asking for password and any confirmation.
I use this command but it asks for password,
ssh root#0.0.0.0 /var/workingproject/notify
is there a way I can whitelist a remote server to access my server and execute a command without asking for password?
You can add your public key, generally found on your local box at ~/.ssh/id_rsa.pub to your remote server's authorized keys file. To do it automatically, you could use something like this:
ssh-copy-id -i ~/.ssh/id_rsa.pub root#0.0.0.0
Or alternatively, you can open the remote authorized keys file (~/.ssh/authorized_keys) and add your public key directly.
If you do not have a public key configured on your local instance, you can run:
ssh-keygen
to create one.

SSH Tunnel Issue [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
I'm trying to tunnel to a remote VM.
I previously used the below command:
ssh -N -p 22 username#1.2.3.4 -o StrictHostKeyChecking=no -L 127.0.0.1:8080:5.6.7.8:443
Something went wrong with the server at the weekend and the SA had to restore the image.
Now when I try to do this I get prompted with the following:
Permission denied, please try again.
username#1.2.3.4's password:
I don't know what this password should be and the SA isn't available.
I am able to ssh directly onto 1.2.3.4 using my public key and when on it I can ssh onto 5.6.7.8 with this command:
ssh -A blueboxadmin#5.6.7.8
Is there any way I can use this to tunnel right through. Failing that, is there anything I can setup on 1.2.3.4 that will allow me to tunnel through?
Looks like the ssh key value pair is missing from the remote server.
You will have to copy the entry of you server ssh key (from $HOME/.ssh/id_rsa.pub file) into the remote server's $HOME/.ssh/authorized_keys file. Make sure the key is pasted in a single line. After doing this, you should be able to connect.

Can I use ssh to login another host and automatically "su" to another user? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
E.g, each time I have start from my mac:
ssh myself#192.168.100.101 to a linux server server and su oracle, and type my password. I wish to accelerate this routine by using some alias, which do the ssh login and su user at the same time.
I know ssh command can do remote command line and quit. But that's not my requirement: I don't wish ssh login/execute/return, I want it to switch user and I start to work.
Any command line option could help on this?
Thanks a lot.
ssh -t myself#192.168.100.101 "su oracle"
-t
Force pseudo-terminal allocation. This can be used to execute
arbitrary screen-based programs on a remote machine, which can be very
useful, e.g. when implementing menu services. Multiple -t options
force tty allocation, even if ssh has no local tty

SSH to remote server [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
this could be a very easy question, I have read some articles but I cannot fit those articles to my situation:
I have from remote.com server a pair of private and public keys (.ppk) for user 'dummy'.
I am in some Unix server (AIX 7.1) and I want to do:
ssh dummy#remote.server with prompt the login
We don't know the password they just provided the keys to log in into the server.
What we have to do?
Just in case: We don't have puttygen and We are not allowed to install it, do we have to ask for PEM format keys?
Making some assumptions:
That the people who have given you the public/private key pair have set up the remote server "dummy" account appropriately
The version of SSH on your local UNIX server is OpenSSH (or something similar)
You need to save the private key you have been given somewhere safe on the filesystem, but this needs to be in the format the local SSH client understands - and for this you will need to run it through 'puttygen'. Does not have to be on the local server, just somewhere to get the right format of key.
ssh -i <identity-file> dummy#<servername>
should do the trick.

SSH port forwarding [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I'm using SSH port forwarding to connect to Windows Remote Desktop from my Linux machine, like this:
ssh -L 50000:192.0.2.10:3389 user#example.com
rdesktop -f localhost:50000 -u user -p password
Now, the first command opens the remote command line on my terminal, so I have to open another terminal to issue the second one. How can I make ssh go on the background so I wouldn't have to open a new terminal?
You can try ssh with -Nf flags. man ssh for more information.

Resources