Transfering postgreSQL DB from one server to another [closed] - bash

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 am using this command to attempt to transfer a DB
pg_dump -C -h localhost -U OLD_SERVER_USER_NAME site_db | psql -h NEW_SERVER_IP -U postgres site_db
It asks me for a password, which I give and then nothing happens, it just hangs.
What am I doing wrong?

First, to avoid the password prompt, you can set the environment variable PGPASSWORD.
In terms of it hanging, it's quite possible that the piping is "eating" an error that you would otherwise see.
Try breaking it up into separate commands, something like:
pg_dump -C -h localhost -U OLD_SERVER_USER_NAME site_db > db.dmp.sql && psql -h NEW_SERVER_IP -U postgres -f db.dmp.sql site_db
And see if you get any errors from either command.

Related

SCP username with colon [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
In order to log into a dedicated server via SSH, i use the following command:
ssh -p 49276 myusername:1001#server.address.net.com
The :1001 after the username is required for me to log in.
I'm now trying to scp some files from this server, using the following command:
scp -P 49276 myusername:1001#server.address.net.com:/var/www /localfolder
But when I do that, I get an error:
Could not resolve hostname myusername: nodename nor servname provided, or not known
I assume it's because of that colon after my username. How would I SCP using these credentials?
This is simply a feature of the Cisso ssh server implementation; it
parses the user name, and if it contains a :[0-9]+ component then it
understands it has to connect the session to the console port with the
corresponding number.
From here https://unix.stackexchange.com/questions/187658/integer-after-username-in-openssh-client-separated-by-colon
Try this:
scp -P 49276 -o User=myusername:1001 server.address.net.com:/var/www /localfolder
This might be a convoluted method, but I believe it will work for your case.
You can define hosts in your ~/.ssh/config file. There you can specify a username to use for a specific hostname. For example -
Host myhostname
User myusername:1001
HostName myhostname.com
Port 49276
With this in your ~/.ssh/config file, you'll be able to use an scp command similar to this -
scp myhostname:/var/www /localfolder
The host will be used together with the specified user and ports in the config file.
A pretty old link, but still useful info on ssh config files:
http://nerderati.com/2011/03/17/simplify-your-life-with-an-ssh-config-file/

linux sshpass not able to execute command remotely [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 2 years ago.
Improve this question
I have remote red-hat 5.4 machine where I am able to execute
sudo lvdisplay
command locally using xyz user but while executing the same command remotely using xyz user through sshpass, I am getting the result as
sudo: lvdisplay: command not found.
The command I am executing is like
sshpass -p 'password' ssh -p 22 -o StrictHostKeyChecking=no
xyz#hostname sudo lvdisplay
.
Please help me out to resolve the issue.
sshpass -p pass ssh -t user#192.168.XXX.XXX 'ls; bash -l'
Try the above command it worked for me. Remember to replace pass and user.

How to open putty using batch and login then execute list of commands on bash [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
I have a Sun OS server with oracle configured on it ; with database 11g i want to take backup , now am connecting to terminal using ssh on putty console but , what i need is finding a way to make it possible to connect using batch to ssh to the server then login then login to oracle then take the backup, is that possible and how.
If you really want to use putty to do this you can use the below in your command prompt in Windows(this will open the putty and its terminal and execute the passed argument in you text file):
putty.exe plink -ssh -load profileName -l username -pw password -m commandPath -t
Or
putty.exe -ssh username#ip -pw password -m commandPath
e.g:
putty.exe -ssh rootz#10.10.10.10 -pw rootzpass -m c:\commands\mycommands.txt
Where profileName is the profile saved in putty and the commandPath is your local directory text file containing the commands you want to execute and the username is the server user and ip is the IP address for the server , the password is your server password then you can put whatever commands you want in your textFile.
Reference
the.earth putty documentation

How to execute a shell script stored on remote machine from a local machine? [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 have a script.sh stored on remote server at some directory, which I want to run from a local computer.
How can I do that in unix using ssh?
You can use ssh command from the local server to execute commands on the remote server. You just have to do something like this:
ssh [user]#[server] '[command]'
In your case, you are trying to execute a shell-script. You can use the same method in the following way:
ssh [user]#[server] /location/of/your/script.sh
You can also run multiple commands in this way:
ssh [user]#[server] '[command 1]; [command 2]; [command 3]'
Or you can also do something like this:
ssh [user]#[server] << EOF
command 1
command 2
command 3
EOF
I assume you have ssh access to your remote server. Type this in a terminal at the local server:
ssh user#remote-server /path/to/script.sh

Change user password in samba server with the pdbedit tool [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 am trying to change user password with script but I'm having trouble using the -t option. Here's what I try:
echo -e "12345\n12345\n" | pdbedit -t -u username
So this is wrong somehow. Any ideas what I am missing or what should I try?
$ printf "%s\n%s\n" pwd pwd|pdbedit -t -r -u user
does not appear to work either
According to http://git.samba.org/?p=samba.git;a=blob;f=source3/utils/pdbedit.c
the --password-from-stdin parameter (pw_from_stdin) only affects account creation.
Thus, you'll rather prefer smbpasswd
$ printf "%s\n%s\n" pwd pwd|smbpasswd -s user
( Piping password to smbpasswd )

Resources